js-ipfs-utils icon indicating copy to clipboard operation
js-ipfs-utils copied to clipboard

fetch and http requests

Open achingbrain opened this issue 4 years ago • 5 comments

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.

achingbrain avatar Nov 18 '21 09:11 achingbrain

Looks like fetch may be coming to node after all: https://github.com/nodejs/node/pull/41749

achingbrain avatar Jan 30 '22 04:01 achingbrain

@achingbrain the issue you've mentioned has been merged.

vladfaust avatar Apr 06 '22 17:04 vladfaust

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).

TinyTb avatar Nov 22 '22 16:11 TinyTb

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 avatar Dec 01 '22 20:12 TJKoury

@TJKoury feel free to submit a PR. It's good to have an open mind to consider proposals

TinyTb avatar Jan 28 '23 06:01 TinyTb