Problem Statement
How can you use async/await in Node.js?
Explanation
You mark a function as async and use await to pause execution until a promise resolves. This makes asynchronous code look synchronous, improving readability and error handling.
Code Solution
SolutionRead Only
async function loadData(){
try{
const res=await fetch('https://api.com');
const data=await res.json();
console.log(data);
}catch(err){console.error(err);}
}