Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api call to get choices on front end and display all choices #28

Merged
merged 1 commit into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion client/src/components/Binary/Choices_appear.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
import React, { Component } from "react";
import { browserHistory } from "react-router";
import axios from "axios";

class ChoicesAppear extends Component {
constructor(props) {
super(props);
this.state = {
choices: []
};
}

componentDidMount() {
const id = this.props.match.params.trialId;
axios
.get(`/choices/${id}`)
.then(res => {
this.setState({ choices: res.data });
})
.catch(err => {
console.log(err);
});
}
render() {
return <div>choices... you have got to pick!</div>;
return (
<div>
{this.state.choices.map((data, index) => (
<div key={index}>
<p>{data.Choices_left}</p>
<p>{data.Choices_right}</p>
</div>
))}
</div>
);
}
}

Expand Down
1 change: 0 additions & 1 deletion client/src/components/Binary/Trial_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class Trial_form extends Component {
handleChange = event => {
const target = event.target;
this.setState({ trialId: randomId(), [target.name]: target.value });
console.log("state: ", this.state);
};

handleSubmit = event => {
Expand Down