ipfs-race
v0.2.3
Published
Resolve an IPFS path using multiple gateways and methods to get data the fastest.
Downloads
520
Readme
IPFS Race
Resolve an IPFS path using multiple gateways and methods to get data the fastest.
npm i ipfs-race
import {resolve} from "ipfs-race";
resolve("QmaiJczLW9X1Gk7rQH7CgYCuquLZMbdWB6hhqznDBoqdLE")
.then(({response, urlResolvedFrom}) => {
console.log("received data first from: ", urlResolvedFrom);
console.log("data: ", await response.json());
})
.catch(console.error);
Node-Fetch Support
If using this library in <16.x.x
versions of node on a backend and not a browser, then you will need to use node-fetch. However, only versions <=2.6.6
will work automatically. If you are using >2.6.6
then you will need to pass in your fetch function manually.
import {resolve} from "ipfs-race";
import fetch from "node-fetch";
resolve("QmaiJczLW9X1Gk7rQH7CgYCuquLZMbdWB6hhqznDBoqdLE", {fetchOverride: fetch})
.then(...)
.catch(console.error);