Async/await
Async/await simplifica, pero hay trampas: promesas sin await, errores no capturados y paralelismo mal usado.
Conceptos clave
- await siempre donde corresponde
- Promise.all para paralelizar
- try/catch por boundary
Ejemplo
async function handler() {
const [a, b] = await Promise.all([fetchA(), fetchB()]);
return { a, b };
}
Ejercicio
- Convierte 2 awaits secuenciales en Promise.all.
- Maneja errores con try/catch y respuesta clara.
Checklist de mastery
- Se paralelizar sin romper.
- No dejo promesas colgadas.