robertvari

Fetch

Feb 17th, 2020
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. state = {
  2.     todos: []
  3. };
  4.  
  5. getTodos(){
  6.     fetch("http://127.0.0.1:8000/api/")
  7.         .then(response => response.json())
  8.         .then(data => this.setState({ todos: data }))
  9.         .catch(err =>{console.log(err)})
  10. }
Advertisement
Add Comment
Please, Sign In to add comment