root 2018-06-06 12:26:56 +02:00
commit 0439506dd1
3 changed files with 20 additions and 19 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -7,6 +7,7 @@
<!-- Latest compiled and minified CSS --> <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<link rel="icon" href="./img/favicon.png" />
<title>Am I late ?</title> <title>Am I late ?</title>
</head> </head>
<body> <body>

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,18 +94,18 @@ 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
}) })
} }
} }
render() { render() {
let currentOptions = this.state.currentResponses.map((element, index) => ( let currentOptions = this.state.currentResponses.map((element, index) => (