Why is nesting .then calls bad in JavaScript?
It defeats the purpose of promises (creating mini callback hell). Instead of nesting, chain flatly. Or use async/await, which is the cleanest way to sequence async operations.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Promise Chaining Pitfalls in JavaScript
Not returning from .then (undefined flows to next), breaking the chain (parallel not sequential), nesting .then (mini callback hell), forgetting .catch (unhandled rejections), sequential instead of parallel await (slow), and wrapping promises in unnecessary new Promise.
Chain .then calls directly: fetchUser(id).then(user => fetchPosts(user)).then(posts => ...). Do not store the promise in a variable and call .then multiple times on it (that runs them in parallel, not sequentially).
The chain continues as fulfilled with the value returned by .catch. If .catch returns 'fallback', the next .then receives 'fallback'. If .catch throws or re-throws, the next .catch catches it.
Still have questions?
Browse all our FAQs or reach out to our support team
