How to recognise when we need the use of await keyword
Hello, consider this code:
Notice I used
await for fetch() and response.json(). I did use that because it's how it's written on MDN but beside that, when do we know something is asynchronous in nature?4 Replies
It’s very simple: any time a function returns a
Promise it’s asynchronous. You either await it or chain .then() methods capped with a .catch() of courseyup noted, thanks !
Just check the docs for the API you’re using and you’ll know.
For example, the fetch API:
https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch#return_value

yep just did that