Generate the REST API Urls in the front-end with this little code-snippet. Don't write:
/someapi/users/123/details?name='abc'&age=20&...
Use the snippet
let url = '/someapi/users/{id}/details';
let urlParams = {id: 123};
let queryParams = {name: 'abc', age: 20 };
buildRestUrl(url, urlParams, queryParams); //someapi/users/123/details?name='abc'&age=20&...
$ npm install nkr_urlbuilder
import { buildRestUrl } from 'nkr_urlbuilder';
let url = '/someapi/users/{id}/details';
let urlParams = {id: 123};
let queryParams = {name: 'abc', age: 20 };
const response = await fetch(buildRestUrl(url, urlParams, queryParams));
Note: First step towards opensource contribution