Video yükleniyor...

Video Yüklenemedi

Ana Sayfaya Dön

You might be using `fetch` wrong...

411,223 görüntüleme • 3 yıl önce •via X (Twitter)

10 Yorum

Steve (Builder.io) profil fotoğrafı
Steve (Builder.io)3 yıl önce

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

Steve (Builder.io) profil fotoğrafı
Steve (Builder.io)3 yıl önce

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

Germinal Camps profil fotoğrafı
Germinal Camps3 yıl önce

Or you could just use axios…

Steve (Builder.io) profil fotoğrafı
Steve (Builder.io)3 yıl önce

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

Tanguy Krotoff profil fotoğrafı
Tanguy Krotoff3 yıl önce

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();

Steve (Builder.io) profil fotoğrafı
Steve (Builder.io)3 yıl önce

Oo I like

Simon Vrachliotis profil fotoğrafı
Simon Vrachliotis3 yıl önce

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

Steve (Builder.io) profil fotoğrafı
Steve (Builder.io)3 yıl önce

Thanks Simon!

Steve (Builder.io) profil fotoğrafı
Steve (Builder.io)3 yıl önce

Wrote more on this in my latest blog post:

Franco Valdes profil fotoğrafı
Franco Valdes3 yıl önce

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.

Benzer Videolar