js-ipfs-utils
js-ipfs-utils copied to clipboard
fetch and http requests
This module exposes a HTTP class that lets you make HTTP requests. It accepts and returns interfaces from the browser fetch spec. Internally it juggles multiple fetch implementations between browsers, node, electron, and react native.
The types of all of these implementations differ to the degree that they are largely incompatible which means we @ts-ignore a bunch of stuff which lets us move on but gives us no type safety and causes all sorts of weird bugs and code gymnastics in other parts of the codebase.
We don't use or need the entirety of the fetch specification. Instead lets stop trying to be a general-purpose polymorphic fetch implementation and instead just expose the bits of the fetch API we use and have each implementation just service those bits.
Looks like fetch may be coming to node after all: https://github.com/nodejs/node/pull/41749
@achingbrain the issue you've mentioned has been merged.
backlog grooming: has come to Node 18, which hasn't come to Electron yet. Will likely be in Electron 22 or 23 (possibly some months away, based on the release schedule).
Also consider moving the imports to static to help with bundlers. ESBuild doesn't like this. Can submit a pull if this is a change that will be considered.
@TJKoury feel free to submit a PR. It's good to have an open mind to consider proposals