← Todas las publicaciones
post24 de abril de 2026
Explica el Encadenamiento de Promesas
#javascript#promises#async#interview
How does promise chaining work? What does each .then return?
Every .then() call returns a NEW Promise. Its resolved value is whatever the callback returns. If the callback returns: - a regular value → next .then receives that value - a Promise → next .then waits for that Promise to resolve - throws an error → control jumps to next .catch ```js fetch('/api/user/1') .then(res => res.json()) // parse body .then(user => fetch(`/api/posts?userId=${user.id}`)) // another request .then(res => res.json()) // parse again .then(posts => render(posts)) // use data .catch(err => showError(err)); // handles ANY error above ``` This is why async/await exists — it's syntactic sugar that makes this chain look synchronous.