Obtendo dados de um axios para outro no 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);
});
}
Dark Donkey