JavaScriptMedium
What is async/await and how does it simplify asynchronous code?
By FrontendPro Editorial Team Updated 8/8/2026
#JavaScript
Answer
async/await is a modern syntax in JavaScript that simplifies working with promises. By using the async keyword before a function, you can use the await keyword inside that function to pause execution until a promise is resolved. This makes asynchronous code look and behave more like synchronous code, making it easier to read and maintain.
js
async function fetchData() {
try {
const response = await fetch(
"https://jsonplaceholder.typicode.com/posts/1",
);
const data = await response.json();
console.log(data);
} catch (error) {
console.error("Error fetching data:", error);
}
}
fetchData();
