Learn Async/Await with JavaScript

Day 7 #100DaysOfCode 💻 Today I learned Using async/await instead of then() with fetch. Normally we do: fetch('https://lnkd.in/gAwJs9UG') .then(res => res.json()) .then(data => console.log(data)); Better approach with async/await: async function getData() { try { const res = await fetch('https://lnkd.in/gAwJs9UG'); const data = await res.json(); console.log(data); } catch(err) { console.error(err); } } getData(); ✨ Reflection: Async/await makes code cleaner, easier to read, and simpler for error handling. #javascript #asyncawait #webdevelopment #100DaysOfCode #Akbiplob

To view or add a comment, sign in

Explore content categories