Getting data from one axios to another in componentDidMount
componentDidMount() {
const {
match: { params }
} = this.props;
axios
.get(`/api/topics/${params.TopicId}`)
.then(response => {
this.setState({ topic: response.data });
return axios.get(`/api/users/${response.data.user_id}`);
})
.then(response => {
this.setState({ user: response.data });
})
.catch(function(error) {
console.log(error);
});
}