Update Route first question

pull/24/head
ayshiff 2018-06-06 11:57:35 +02:00
parent e5ecac5ce9
commit b445fbd7e1
1 changed files with 19 additions and 19 deletions

View File

@ -50,11 +50,11 @@ class App extends Component {
score: 0 score: 0
}); });
axios.get(this.state.baseRoute+"/questions" +"?q="+new Date().getTime()) axios.get(this.state.baseRoute + "/questions/first"+ "?q=" + new Date().getTime())
.then(((data) => { .then(((data) => {
this.fetchQuestion(this.state.baseRoute+"/questions/"+data.data[0].id); this.fetchQuestion(this.state.baseRoute+"/questions/"+data.data[0].id);
this.fetchResponses(this.state.baseRoute+"/questions/"+data.data[0].id+"/responses"); this.fetchResponses(this.state.baseRoute + "/questions/" + data.data[0].id + "/responses");
})); }))
} }
_handleClick(element) { _handleClick(element) {
@ -74,7 +74,7 @@ class App extends Component {
} }
fetchQuestion(url) { fetchQuestion(url) {
axios.get(url +"?q="+new Date().getTime()) axios.get(url)
.then(((data) => { .then(((data) => {
console.log(data.data); console.log(data.data);
this.setState({ this.setState({
@ -86,7 +86,7 @@ class App extends Component {
} }
fetchResponses(url) { fetchResponses(url) {
axios.get(url +"?q="+new Date().getTime()) axios.get(url)
.then(((data) => { .then(((data) => {
this.setState({ this.setState({
currentResponses : data.data currentResponses : data.data
@ -94,14 +94,14 @@ class App extends Component {
})) }))
} }
componentWillMount(){ componentWillMount() {
if(this.state.start === true) { if (this.state.start === true) {
axios.get(this.state.baseRoute+"/questions" +"?q="+new Date().getTime()) axios.get(this.state.baseRoute + "/questions/first"+ "?q=" + new Date().getTime())
.then(((data) => { .then(((data) => {
this.fetchQuestion(this.state.baseRoute+"/questions/"+data.data[0].id); this.fetchQuestion(this.state.baseRoute+"/questions/"+data.data[0].id);
this.fetchResponses(this.state.baseRoute+"/questions/"+data.data[0].id+"/responses"); this.fetchResponses(this.state.baseRoute + "/questions/" + data.data[0].id + "/responses");
})); }))
this.setState ({ this.setState({
start: false start: false
}) })
} }