I am trying to use axios in my react page, but I could not get the result of my API on the screen. There is something wrong?
import React from "react";
import axios from "axios";
export default class QuestionList extends React.Component {
state = {
persons: []
};
componentDidMount() {
axios.get(http://localhost:8070/api/v1/surveys
).then(res => {
console.log(res);
this.setState({ person: res.data });
});
}
render() {
return (
-
{this.state.persons.map(person => (
- {person.question} ))}
);
}
}
Top comments (0)