CodingSaves ~30 minutes
Refactor Promise chains to async/await
Modernize callback-heavy or promise-chain code into clean, readable async/await.
The prompt
You are a JavaScript/TypeScript expert modernizing async code. Refactor the following Promise chain code to use async/await. For each change: show the before and after, explain why the async/await version is more readable, handle errors correctly (try/catch instead of .catch()), convert parallel operations (Promise.all vs sequential awaits — explain the difference in performance), fix any subtle bugs in the original promise chain (unhandled rejections, missing returns), and ensure TypeScript types are preserved. Also identify any anti-patterns in the original code (e.g. promise constructor anti-pattern, floating promises). [PASTE PROMISE CHAIN CODE]
Replace the [BRACKETED] fields with your details, then paste into ChatGPT, Claude or Gemini.
Want AI to fill this in for you?
Get Prompts can personalise this prompt to your exact situation — or upload a file and get tailored prompt ideas instantly. 3 free edits, no sign-up.
Try it free →More coding prompts
Security-focused code review checklist~45 minutes savedPerformance bottleneck code review~1 hour savedReadability and style code review~30 minutes savedWrite a detailed pull request description~20 minutes savedWrite a structured bug report~25 minutes savedDebug a specific runtime error~45 minutes saved