Loading video...
Video Failed to Load
You might be using `fetch` wrong...
411,232 views • 3 years ago •via X (Twitter)
10 Comments

If you are interested in wretch, the tiny wrapper around fetch, you can learn more about it here

For a cool trick to make `fetch` more intuitive without using any libraries see pt 2 here:

Or you could just use axios…

True, though it is over 5x larger (11kb gzip vs 1.9kb gzip), so if perf is important for your site/app minimizing kb can be valuable

I've written a small fetch wrapper (~250 lines) that does this. - Comes with test utilities - Supports Node.js & web browsers - Written in TypeScript - Fully tested const response = await postJSON(url, data).json();

Oo I like

The delivery on these tips is amazing, congrats! Love the karaoke-like transcript progress 👍

Thanks Simon!

Wrote more on this in my latest blog post:

That was one of my biggest issues when fetch came out. I wish non 200 responses would automatically fall into the catch but they do not.
Related Videos
Why You Might Be Using The Wrong Fuel! Advice from car expert
CLEAN CAR CLUB
47,139 views • 1 year ago
