Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React js nested axios call

Tags:

reactjs

axios

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

like image 808
user4900074 Avatar asked Jul 06 '17 20:07

user4900074


1 Answers

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);
  });
like image 176
Chase DeAnda Avatar answered Sep 21 '22 23:09

Chase DeAnda