14 lines
400 B
JavaScript
14 lines
400 B
JavaScript
|
export function assembleURLAndParams (endpoint, params) {
|
||
|
var url = endpoint + "?";
|
||
|
Object.keys(params).forEach(
|
||
|
key => {
|
||
|
if (Array.isArray(params[key])) {
|
||
|
params[key].forEach(value => url += key + "[]=" + value + "&");
|
||
|
} else {
|
||
|
url += key + "=" + params[key] + "&";
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
return url.rstrip("&");
|
||
|
}
|