axios integrates better with TypeScript interfaces, however, fetch (and well as node-fetch) has much more predictable output.
// Is it `string` or `Record<string, unknown>` (or `Blob`)?const{data}=awaitaxios.get('/api')// Nearly always `Record<string, unknown>`constdata2=awaitfetch('/api').then((r)=>r.json())
Also, fetch can be attached AbortController. I would be interested in a library built on top fetch.
I know there are superagent and ky, but I never really tried.
axios
integrates better with TypeScript interfaces, however,fetch
(and well asnode-fetch
) has much more predictable output.Also,
fetch
can be attachedAbortController
. I would be interested in a library built on topfetch
.I know there are superagent and ky, but I never really tried.
What about?
Now
data
is an array of objectsFruit
Actually, it's just a fake typing.
It depends on the "real" data, whether it gets
JSON.parse()
or not.