Skip to content

Commit

Permalink
Merge pull request 99x#51 from dinukadesilva/99xgh-50
Browse files Browse the repository at this point in the history
99xgh-50: Moved the `todos` `init` method execution to `componentDidMount`
  • Loading branch information
mjzone authored Aug 28, 2017
2 parents e0ec68a + ba75884 commit adf7b6b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion web/src/components/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ export default class App extends React.Component {
this.state = {
todos
};
this.init();
this.init = this.init.bind(this);
}

componentDidMount() {
this.init();
}

init() {
var self = this;
axios.get(BASE_URL + '/todos/getAll').then(function(response) {
self.setState({todos: response.data.result.Items});
}).catch(function(error) {
self.setState({todos: [{}, {}]});
console.log(error);
});
}
Expand Down

0 comments on commit adf7b6b

Please sign in to comment.