Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What does this library solve that fetch does not? #9

Open
PaulBGD opened this issue Sep 2, 2017 · 14 comments
Open

What does this library solve that fetch does not? #9

PaulBGD opened this issue Sep 2, 2017 · 14 comments

Comments

@PaulBGD
Copy link

PaulBGD commented Sep 2, 2017

No description provided.

@st-schneider
Copy link

And what would be the benefits over libs like axios?

@tuananh
Copy link

tuananh commented Sep 4, 2017

my guess is that same api between node and browser?

@ruanyl
Copy link

ruanyl commented Sep 4, 2017

my guess is that same api between node and browser?

But fetch has its own specification: https://fetch.spec.whatwg.org/
Maybe I didn't get the key point, but isn't this repo just a wrap of fetch?

@ljharb
Copy link

ljharb commented Sep 4, 2017

The purpose of fetch is to be a low level primitive that libraries wrap; it's not really meant to be used directly.

@dandv
Copy link

dandv commented Sep 5, 2017

How does this library compare with @bitinn's node-fetch ?

@batjko
Copy link

batjko commented Sep 10, 2017

As far as I can see, it adds only two things over fetch:

  1. It automatically uses a polyfill if used in node (via node-fetch), and
  2. it lowercases headers for you.

And the rest is largely just recreating fetch's API.
Granted, this could be done easily manually, but as a simple and small wrapper, this one will do the job quickly.

@abenhamdine
Copy link

FWIW, one could also be interested in checking wretch https://github.com/elbywan/wretch which is also a tiny wrapper around fetch.

@mikemaccana
Copy link

mikemaccana commented Sep 28, 2017

Lots of thumbs down but @ljharb 's comment is accurate: Fetch's author specifically states he designed it as a low level HTTP/S client. Hence fetch doesn't use content types, encode query strings, etc.

Personally I'd like to see a high level API with those things built on top of fetch.

@gr2m
Copy link
Collaborator

gr2m commented Feb 27, 2018

As this seems to be a common question, it would be nice to address it in the README

@DevBrent
Copy link

DevBrent commented Aug 22, 2018

The primary reasons I like r2 are that it is a very small nearly transparent library and you do not have to do two awaits to get the response data. e.g. await (await fetch(url)).text() vs await r2(url).text.

@phil-lgr
Copy link

phil-lgr commented Aug 6, 2019

for one, node-fetch does not support https (certificate and key) like request

see node-fetch/node-fetch#15 (comment)

@phil-lgr
Copy link

phil-lgr commented Aug 6, 2019

oh, actually node-fetch supports https / ca / cert and key: node-fetch/node-fetch#15 (comment)

@mrchief
Copy link

mrchief commented Aug 6, 2019

Lots of thumbs down but @ljharb 's comment is accurate: Fetch's author specifically states he designed it as a low level HTTP/S client. Hence fetch doesn't use content types, encode query strings, etc.

All it lacks is a citation...

@ljharb
Copy link

ljharb commented Aug 6, 2019

Google yielded https://medium.com/cameron-nokes/4-common-mistakes-front-end-developers-make-when-using-fetch-1f974f9d1aa1 , but a better source is https://jakearchibald.com/2015/thats-so-fetch/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests