Created
July 13, 2020 14:03
-
-
Save Shelob9/9fdb3c67039747a795e0a7631281c455 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
function(endpoint,args={}){ | |
//parse url | |
//https://developer.mozilla.org/en-US/docs/Web/API/URL | |
let url = new URL(endpoint); | |
//Add params | |
Object.keys(args).forEach( arg => { | |
//https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams/URLSearchParams | |
url.searchParams.append( arg, args[arg] ); | |
}); | |
return url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment