Skip to content

Resolve an IPFS path using multiple gateways and methods to get data the fastest.

Notifications You must be signed in to change notification settings

Frame-One-Software/ipfs-race

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IPFS Race

NPM NPM GITHUB

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

About

Resolve an IPFS path using multiple gateways and methods to get data the fastest.

Resources

Stars

Watchers

Forks

Packages

No packages published