Skip to content

Instantly share code, notes, and snippets.

@joefusaro
Last active December 4, 2016 23:27
Show Gist options
  • Save joefusaro/4e09d0949e80dcbb1a02e01405dbc360 to your computer and use it in GitHub Desktop.
Save joefusaro/4e09d0949e80dcbb1a02e01405dbc360 to your computer and use it in GitHub Desktop.
import React from 'react';
class ChangeList extends React.Component {
constructor() {
super();
this.state={items:[]};
}
componentDidMount(){
fetch(`http://127.0.0.1:8000/backup/changes/1/Lead.json`)
.then(result=>result.json())
.then(({ results })=>this.setState( {items: results} ))
}
render() {
return(
<ul>
{this.state.items.length ?
this.state.items.map(item => <li key={item.id}> {item.name}, {item.id} </li>)
: <li>Loading...</li>
}
</ul>
)
}
}
export default ChangeList
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment