Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. class App extends Component {
  2. state = {users: []}
  3.  
  4. componentDidMount() {
  5. fetch('/users')
  6. .then(res => {
  7. console.log(res);
  8. return res.json()
  9. })
  10. .then(users => {
  11. console.log(users);
  12. this.setState({ users })
  13. });
  14. }
  15.  
  16. render() {
  17. return (
  18. <div className="App">
  19. <h1>Users</h1>
  20. {this.state.users.map(user =>
  21. <div key={user.id}>user: {user.name} Password: {user.password}</div>
  22. )}
  23. </div>
  24. );
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement