Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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);
    });
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: Read data in props.histroy.push in react component 
Javascript :: xamarin forms create components from json 
Javascript :: display prety html json data 
Javascript :: 4.3.1. Declaring and Initializing Variables With let¶ 
Javascript :: 4.8.3. Critical Input Detail¶ 
Javascript :: Insert a custom object 
Javascript :: grotesque meaning 
Javascript :: google script isnan 
Javascript :: add object to object dynamically 
Javascript :: distructuring null check 
Javascript :: 8.1.1. Declaring an Array¶ 
Javascript :: delete multiple nodes in firebase realtime database 
Javascript :: javascript substtgin 
Javascript :: 10.3.1. Function Syntax 
Javascript :: Using Math Functions in an IF statement 
Javascript :: element.queryselector possibly null 
Javascript :: bar code react native 
Javascript :: invoke method inside class javascript 
Javascript :: javascript check if string contains capital letter 
Javascript :: best way to store db config in node js 
Javascript :: Assign keys to an object with the same name 
Javascript :: expect(insTypeDB).is.to.equals(61) on javascript 
Javascript :: https://web.roblox.com/users/20732870/profile 
Javascript :: force reload when back_forward is clicked 
Javascript :: regexp substr tester 
Javascript :: value 
Javascript :: javascript set css after property 
Javascript :: javascript verbatim string 
Javascript :: convert componentDidUpdate into useEffect 
Javascript :: setting a date range using yup on react date picker 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =