Skip to content

Instantly share code, notes, and snippets.

@mdshadman
Last active October 24, 2019 18:25
Show Gist options
  • Save mdshadman/186c470c58d4421d27b729449c958412 to your computer and use it in GitHub Desktop.
Save mdshadman/186c470c58d4421d27b729449c958412 to your computer and use it in GitHub Desktop.
goForFetch = () => {
this.setState({
fromFetch: true,
loading: true,
})
fetch("https://jsonplaceholder.typicode.com/users")
.then(response => response.json())
.then((responseJson) => {
console.log('getting data from fetch', responseJson)
setTimeout(() => {
this.setState({
loading: false,
dataSource: 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