Open PaulBGD opened 7 years ago
my guess is that same api between node and browser?
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?
The purpose of fetch is to be a low level primitive that libraries wrap; it's not really meant to be used directly.
How does this library compare with @bitinn's node-fetch ?
As far as I can see, it adds only two things over fetch:
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.
FWIW, one could also be interested in checking wretch https://github.com/elbywan/wretch which is also a tiny wrapper around fetch.
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.
As this seems to be a common question, it would be nice to address it in the README
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
.
for one, node-fetch
does not support https (certificate and key) like request
see https://github.com/bitinn/node-fetch/issues/15#issuecomment-97295714
oh, actually node-fetch supports https / ca / cert and key: https://github.com/bitinn/node-fetch/issues/15#issuecomment-97368725
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...
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/
And what would be the benefits over libs like axios?