在功能组件中调用的多重API reactjs

问题描述 投票:0回答:2
reactjs axios react-functional-component
2个回答
0
投票
使用可以使用以下异步函数。一旦第一个请求解决,由于异步等待,它将移至下一行。


const onSearch =  async () => {
    try {
      const responseA = await A();
      const responseB = await B();
    }catch(e){
      console.log(e,'error');
    }
  }

0
投票

您可以将这两个召唤组合成一个呼叫。例如
axios.get

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.