Skip to content

Instantly share code, notes, and snippets.

@satty1987
satty1987 / query
Created Sep 10, 2020
URL Query Builder
View query
replaceParams (endPoint, params) {
if (angular.isString(endPoint)) {
if (params) {
angular.forEach(params, function (val, key) {
endPoint = endPoint.replace('[' + key + ']', val); //First look for optional params
endPoint = endPoint.replace('{' + key + '}', val);
});
}
endPoint = endPoint.replace(/(\[[^\[]*\])/g, ''); //Replace undefined optional param holders