@unfuck/fetch
v0.0.4
Published
It's just fetch with a few DX improvements:
Downloads
3
Readme
Unfucked fetch
It's just fetch with a few DX improvements:
Data is cached on the object once retrieved from the stream so it isn't destroyed (removes need to clone entire object for simple situations).
Provides convenience 'gimme' method that will attempt to interpret data type based on headers and return data from relevant stream method.
Each of these features are provided on a custom FkResponse with overloads for the data retrieval methods.
Throws a fucking error. I prefer returned errors over throws too, they are the way errors should be done. BUT, when the rest of the language/ecosystem is built around throw/try-catch it makes things really, really annoying to have one common method that is different. Also not having a proper, ubiquitous option type kinda makes returned errors suck (still love you tho Go).
Throws
http-errors
except for the customNetworkError
. If anyone knows of a better more TS friendly error lib I'll use that, or make my own.You can use
fkFetch
method directly the same asfetch
or usecreateFkFetch
to make your own instance with custom MIME type mapping.Decided not to Monkey-Patch fetch as this does change the use patterns considerably.
Auto-capitalizes 'patch' to 'PATCH', because, come on... Nobody cares if it's not a standard verb, it's used nearly everywhere. The fact you have to point out in the docs that you must manually capitalize it is CLEAR a sign that it should be done automatically.