Answers for "Getting data from one axios to another in componentDidMount"

0

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);
    });
}
Posted by: Guest on June-04-2021

Code answers related to "Getting data from one axios to another in componentDidMount"

Browse Popular Code Answers by Language