Skip to content

Instantly share code, notes, and snippets.

@LishuGupta652
Created October 24, 2023 15:27
Show Gist options
  • 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