"Struggling with REST API request javascript—any tips?"
Hey guys,
I’ve been trying to figure out how to make a rest api request javascript style, but it’s not working like I expected.
Tried using `fetch()`, but sometimes it just... doesn’t do anything? Or I get weird errors.
Am I missing something obvious? Like, do I *always* need to handle the response with `.then()`? And what’s the deal with async/await here?
Also, how do you guys handle errors? My code just crashes if the API is down lol.
Any quick examples or common pitfalls to avoid? Thanks in advance!
(PS: If you’ve got a favorite library for this, lmk!)
Hey guys,
I’ve been trying to figure out how to make a rest api request javascript style, but it’s not working like I expected.
Tried using `fetch()`, but sometimes it just... doesn’t do anything? Or I get weird errors.
Am I missing something obvious? Like, do I *always* need to handle the response with `.then()`? And what’s the deal with async/await here?
Also, how do you guys handle errors? My code just crashes if the API is down lol.
Any quick examples or common pitfalls to avoid? Thanks in advance!
(PS: If you’ve got a favorite library for this, lmk!)
