How to use data as a result from api call as a response in another concurrently?
I've got this function
const foo = async() => {
await firstCall()
await secondCall()
}
calling firstCall()
i want to get data and save them inside some variable and when this data is received use data as params inside secondCall()
CodePudding user response:
Declare a variable data
inside your async function foo
and assign it a value which is the value returned from calling the firstCall
function:
const foo = async() => {
const data = await firstCall()
await secondCall(data)
}
For more info you can read documentations at MDN - async function.