Last active
March 6, 2022 10:38
-
-
Save ridvansumset/d65ae44b24647a6a69342254ac20622c 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
getFullPath(path, params = null, query = null) { | |
let ret = path; | |
if (params) { | |
for (const key in params) { | |
if (Object.prototype.hasOwnProperty.call(params, key)) { | |
ret = ret.replace(`:${key}`, params[key]); | |
} | |
} | |
} | |
if (query) { | |
ret += '?'; | |
let i = 0; | |
for (const key in query) { | |
if (Object.prototype.hasOwnProperty.call(query, key)) { | |
if (i > 0) { | |
ret += '&'; | |
} | |
ret += `${key}=${encodeURIComponent(query[key])}`; | |
i += 1; | |
} | |
} | |
} | |
return ret; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment