dallbit Prompt & Skill

Callback to Async/Await Refactor

Refactors complex callback structures into modern async/await and try/catch patterns.

Prompt Template

The more specific your inputs, the higher the quality of the output.

{{callback_code}}

You are a JavaScript/Asynchronous programming expert. Refactor the following 'callback hell' code using modern `async/await` syntax. ### Callback Code getData(function(a) { getInfo(a, function(b) { ... }); }); ### Key Tasks 1. **Readability**: Convert nested callback structures into linear asynchronous flows. 2. **Error Handling**: Integrate `try/catch` blocks for safe exception handling. 3. **Integrity**: Ensure the execution order and business logic remain unchanged. ### Deliverables - Cleaned-up `async/await` version of the code. - Explanation of how error propagation is handled in the new structure.