Merge pull request #16 from SundownDEV/devFront

Update first element array in ComponentWillMount
pull/17/head
Rémi Doreau 2018-06-05 20:06:56 +02:00 committed by GitHub
commit e10c5380f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -50,8 +50,11 @@ class App extends Component {
componentWillMount(){
if(this.state.start === true) {
this.fetchQuestion(this.state.baseRoute+"/questions/1");
this.fetchResponses(this.state.baseRoute+"/questions/1/responses");
axios.get(this.state.baseRoute+"/questions")
.then(((data) => {
this.fetchQuestion(this.state.baseRoute+"/questions/"+data.data[0].id);
this.fetchResponses(this.state.baseRoute+"/questions/"+data.data[0].id+"/responses");
}))
this.setState ({
start: false
})