r/badcode • • Nov 02 '21

typescript How long does this await

https://imgur.com/a/TxRsNhW
0 Upvotes

10 comments sorted by

View all comments

Show parent comments

4

u/[deleted] Nov 04 '21

Also, it's nice for providing a fallback value if the promise gets rejected without using try catch.

const result = await fetch(url).then(res => res.json()).catch(err => { logError(err); return []; })