Skip to content

Commit d575466

Browse files
committed
api call to get choices on front end and display all choices
relates to #8
1 parent 9fec991 commit d575466

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

client/src/components/Binary/Choices_appear.js

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,37 @@
11
import React, { Component } from "react";
22
import { browserHistory } from "react-router";
3+
import axios from "axios";
34

45
class ChoicesAppear extends Component {
6+
constructor(props) {
7+
super(props);
8+
this.state = {
9+
choices: []
10+
};
11+
}
12+
13+
componentDidMount() {
14+
const id = this.props.match.params.trialId;
15+
axios
16+
.get(`/choices/${id}`)
17+
.then(res => {
18+
this.setState({ choices: res.data });
19+
})
20+
.catch(err => {
21+
console.log(err);
22+
});
23+
}
524
render() {
6-
return <div>choices... you have got to pick!</div>;
25+
return (
26+
<div>
27+
{this.state.choices.map((data, index) => (
28+
<div key={index}>
29+
<p>{data.Choices_left}</p>
30+
<p>{data.Choices_right}</p>
31+
</div>
32+
))}
33+
</div>
34+
);
735
}
836
}
937

client/src/components/Binary/Trial_form.js

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class Trial_form extends Component {
1212
handleChange = event => {
1313
const target = event.target;
1414
this.setState({ trialId: randomId(), [target.name]: target.value });
15-
console.log("state: ", this.state);
1615
};
1716

1817
handleSubmit = event => {

0 commit comments

Comments
 (0)