Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
64 lines (59 sloc) 1.67 KB
<br />
<a href="/tasks/new">[ new ] </a>
<hr />
<div id="app"></div>
<!-- -->
<script type="text/babel">
//
class List extends React.Component {
constructor(props) {
super(props);
this.state = {data: ''}
}
componentDidMount(){
axios.get('/api/tasks_index').then(response => {
this.setState({ data: response.data.docs })
console.log( response.data.docs )
})
.catch(function (error) {
console.log(error)
})
}
tabRow(){
if(this.state.data instanceof Array){
return this.state.data.map(function(row, index){
return (
<tr key={index}>
<td>
<a href={"/tasks/show/"+row._id}>{row._id}</a><br />
</td>
<td>{row.title}</td>
<td>{row.content}</td>
<td><a href={"/tasks/edit/"+row._id}>[ edit ]</a></td>
</tr>
)
})
}
}
render(){
return (
<div>
<h1>index</h1>
<table className="table table-hover">
<thead>
<tr>
<td>ID</td>
<td>Title</td>
<td>content</td>
</tr>
</thead>
<tbody>
{this.tabRow()}
</tbody>
</table>
</div>
)
}
}
ReactDOM.render(<List />, document.getElementById('app'));
</script>
You can’t perform that action at this time.