Skip to content

Instantly share code, notes, and snippets.

@syamjayaraj
Created August 7, 2018 18:28
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 syamjayaraj/83b6a725ef8493cc530f1e90f904c17c to your computer and use it in GitHub Desktop.
Save syamjayaraj/83b6a725ef8493cc530f1e90f904c17c to your computer and use it in GitHub Desktop.
componentDidMount() {
this.timer=setInterval(() =>this.getDonor(), 1000);
}
async getDonor() {
return fetch(`https://blood-donors-db.firebaseio.com/donors.json`)
.then((response) => response.json())
.then((responseJson) => {
this.setState({
donors: Object.values(responseJson),
});
})
.catch((error) => {
console.error(error);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment