Skip to content

Instantly share code, notes, and snippets.

@johandalabacka
Created April 26, 2022 13:09
Show Gist options
  • Save johandalabacka/dac74d2bf3d2c00ed1fa71b43591658b to your computer and use it in GitHub Desktop.
Save johandalabacka/dac74d2bf3d2c00ed1fa71b43591658b to your computer and use it in GitHub Desktop.
fetchWithParams
function fetchWithParams(resource, params, init) {
const u = resource instanceof URL ? resource : new URL(resource)
for([k,v] of Object.entries(params)) {
u.searchParams.set(k, v)
}
return fetch(u, init)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment