Skip to content

Instantly share code, notes, and snippets.

@devotdev
Created December 18, 2024 09:27
Show Gist options
  • Save devotdev/4a2b43975d95c30ff3b6b3150f0771e6 to your computer and use it in GitHub Desktop.
Save devotdev/4a2b43975d95c30ff3b6b3150f0771e6 to your computer and use it in GitHub Desktop.
Working with asynchronous operations example
const fetchUserData = async function(userId) {
const response = await fetch(`https://api.example.com/users/${userId}`);
const data = await response.json();
return data;
}
fetchUserData(1).then(user => console.log(user));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment