R
Reactiflux

✅ – Script – 21-40 Nov 19

✅ – Script – 21-40 Nov 19

SScript11/19/2022
is it recommended to run another api request in the .then method of an api request?
SScriptyChris11/19/2022
I think it's better to do it in another step in promise chain, because nesting .then() will lead to kind of callback hell 😛 @Script So it's better to do either:
someAsyncStuff()
.then(() => {
return someOtherAsyncStuffReturningPromise()
})
.then(() => {
return yetAnotherAsyncStuffReturningPromise()
})
// ... another `.then()` or nothing
someAsyncStuff()
.then(() => {
return someOtherAsyncStuffReturningPromise()
})
.then(() => {
return yetAnotherAsyncStuffReturningPromise()
})
// ... another `.then()` or nothing
const promise = await someAsyncStuff();
const someOtherPromise = await someOtherAsyncStuffReturningPromise();
const yetAnotherPromise = await yetAnotherAsyncStuffReturningPromise();
const promise = await someAsyncStuff();
const someOtherPromise = await someOtherAsyncStuffReturningPromise();
const yetAnotherPromise = await yetAnotherAsyncStuffReturningPromise();
SScript11/20/2022
word
UUUnknown User11/20/2022
3 Messages Not Public
Sign In & Join Server To View

Looking for more? Join the community!

R
Reactiflux

✅ – Script – 21-40 Nov 19

Join Server