React js嵌套的axios调用

use*_*074 3 reactjs axios

我如何进行嵌套axios呼叫?我需要将第一个axios调用的结果作为参数传递给第二个axios

Cha*_*nda 7

您可以像正常的承诺一样进行连锁。触发第一个请求中的.then下一个请求,然后返回该承诺,这样您将获得.then第二个请求。

axios.get(...)
  .then((response) => {
    return axios.get(...); // using response.data
  })
  .then((response) => {
    console.log('Response', response);
  });
Run Code Online (Sandbox Code Playgroud)