Last active
September 4, 2018 05:41
-
-
Save NetanelBasal/d169a5a4f0f8b7ce8be1203f939f012b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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