if youre new to js or just wanna brush up your async handling skills with, these might help ⚡
first off, remember:
`async/await is a friend of yours here`. it makes waiting for responses feel more like synchronous code . once u wrap ur fetch in an `async function`, you can use the keyword to wait until your request completes before moving on.
secondly, always handle errors with `. catch()`:
fetch(url). then(response => response. json()). catch(error => console. log('Error:', error))
this helps keep things from breaking when something goes wrong
last but not least:
use `const` or let for your variables . in async land, you need to make sure ur data is accessible after the fetch completes.
anyone else struggle with at first? i did! now its my go-to method
link:
https://medium.com/better-programming/3-fundamental-concepts-to-fully-understand-how-the-fetch-api-works-3ee5d41f81a4?source=rss----d0b105d10f0a---4