Skip to content

Instantly share code, notes, and snippets.

@vaibhavgehani
Created August 7, 2022 13:40
Show Gist options
  • Save vaibhavgehani/82d14915713f26252bdb3b39c0e1d407 to your computer and use it in GitHub Desktop.
Save vaibhavgehani/82d14915713f26252bdb3b39c0e1d407 to your computer and use it in GitHub Desktop.
const goForFetch = () => {
setFromFetch(true);
setLoading(true);
fetch("https://jsonplaceholder.typicode.com/users")
.then(response => response.json())
.then((responseJson) => {
console.log('getting data from fetch', responseJson)
setTimeout(() => {
setLoading(false);
setDataSource(responseJson)
}, 2000)
})
.catch(error => console.log(error))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment