Script
Script3y ago

✅ – Script – 21-40 Nov 19

is it recommended to run another api request in the .then method of an api request?
4 Replies
ScriptyChris
ScriptyChris3y 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();
Script
ScriptOP3y ago
word
reactibot
reactibot3y ago
This question has an answer! Thank you for helping 😄 If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1043642028585664523
reactibot
reactibot3y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1043642028585664523 Question not getting answered? Maybe it's hard to answer, or maybe you asked at a slow time. Check out these resources for help asking a good question: https://stackoverflow.com/help/how-to-ask http://wp.me/p2oIwo-26