[如何使用react / redux saga异步API调用后访问数据?以下更多信息

问题描述 投票:0回答:1

技术使用:React,Redux,Saga从第二个函数调用之后,如何访问数据? firstFunction继续执行其余代码。我尝试了async / await,但是它不起作用。

   firstFunction (()=>{
  secondFunctionAPI() //using Redux and Saga
   // Here I want to use the data from the response of secondFunction().
more code...
more code..
})
reactjs api redux redux-saga saga
1个回答
0
投票

您可以将要执行的代码作为回调传递给secondFunctionAPI

firstFunction(() => {
  secondFunctionAPI((data) => {
    // code using data
  })
})
© www.soinside.com 2019 - 2024. All rights reserved.