Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Created July 13, 2020 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shelob9/9fdb3c67039747a795e0a7631281c455 to your computer and use it in GitHub Desktop.
Save Shelob9/9fdb3c67039747a795e0a7631281c455 to your computer and use it in GitHub Desktop.
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