From 3b3260cc784fd51a6febb7546a8abe4069501853 Mon Sep 17 00:00:00 2001 From: ayshiff Date: Tue, 5 Jun 2018 18:49:36 +0200 Subject: [PATCH] Update first element array --- client/src/App.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/src/App.js b/client/src/App.js index fabd611..b31a8f9 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -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 })