Skip to content

Instantly share code, notes, and snippets.

@protomorph
Created August 14, 2022 23:44
Show Gist options
  • Save protomorph/ceb8e36ae511948c5d3b4560388a1d78 to your computer and use it in GitHub Desktop.
Save protomorph/ceb8e36ae511948c5d3b4560388a1d78 to your computer and use it in GitHub Desktop.
function getFetch(url, params = {}) {
const queryString = Object.entries(params).map(
param => `${param[0]}=${param[1]}`
).join('&')
return fetch(`${url}?${queryString}`, {
method: "GET",
headers: { "Content-Type": "application/json" }
}).then(res => res.json())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment