Skip to content

Instantly share code, notes, and snippets.

@NetanelBasal
Last active September 4, 2018 05:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NetanelBasal/d169a5a4f0f8b7ce8be1203f939f012b to your computer and use it in GitHub Desktop.
Save NetanelBasal/d169a5a4f0f8b7ce8be1203f939f012b to your computer and use it in GitHub Desktop.
class API {
...
resolve(url: string, params?) {
if (!params) {
return `${this._baseUrl}${url}`;
}
const resolved = Object.keys(params).reduce((acc, param) => {
return acc.replace(`:${param}`, params[param]);
}, url);
return `${this._baseUrl}${resolved}`;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment