Skip to content

Instantly share code, notes, and snippets.

@LishuGupta652
Created October 24, 2023 15:27
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 LishuGupta652/07fc75609a23541296001f31f63cd681 to your computer and use it in GitHub Desktop.
Save LishuGupta652/07fc75609a23541296001f31f63cd681 to your computer and use it in GitHub Desktop.
async function getUser(url) {
try {
const response = await fetch(url, {
method: 'GET',
headers: {
accept: 'application/json',
},
});
if (!response.ok) {
throw new Error(`Error! status: ${response.status}`);
}
const result = await response.json();
return result;
} catch (err) {
console.log(err);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment