React Js Nested Axios Call

React Js Nested Axios Call

How can i make nested axios call? I need to pass the result of first axios call as parameter to second axios

1

1 Answer

You can chain just like a normal promise. Fire off the next request in the .then of the first request and then return that promise so you'll have a .then for you second request.

axios.get(...)
  .then((response) => {
    return axios.get(...); // using response.data
  })
  .then((response) => {
    console.log('Response', response);
  });
4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller
Author

David Miller

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.