Created
April 26, 2022 13:09
-
-
Save johandalabacka/dac74d2bf3d2c00ed1fa71b43591658b to your computer and use it in GitHub Desktop.
fetchWithParams
This file contains hidden or 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 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