✅ – Script – 21-40 Nov 19

is it recommended to run another api request in the .then method of an api request?
S
ScriptyChris514d ago
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();
S
Script514d ago
word
UU
Unknown User513d ago