SilentCicero / ipfs-mini

A super tiny module for querying IPFS that works in the browser and node.
MIT License
152 stars 40 forks source link

Option to add Infura key. #10

Open ChrisCates opened 5 years ago

ChrisCates commented 5 years ago

Issue Type

Description

I noticed you guys are using Infura in the example. However, when I try to query Infura... I get an ECONNREFUSED error... Looking at the docs here: https://infura.io/docs/ipfs/get/block_get.

It's clear that I need to have an infura key in order to query the IPFS storage... Shouldn't I be able to add a key for infura in the query string?

Steps to reproduce

$ node
> const IPFS = require('ipfs-mini');
undefined
> const ipfs = new IPFS({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });
undefined
> 
> ipfs.cat('QmTp2hEo8eXRp6wg7jXv1BLCMh5a4F3B7buAUZNZUu772j', (err, result) => {
...   console.log(err, result);
... });
undefined
> Error: [ipfs-mini] status 0: Error: connect ECONNREFUSED 34.237.60.131:5001
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
    at exports.XMLHttpRequest.request.onreadystatechange (/Users/chriscates/Projects/UniversalLoginSDK/node_modules/ipfs-mini/lib/index.js:56:18)
    at exports.XMLHttpRequest.dispatchEvent (/Users/chriscates/Projects/UniversalLoginSDK/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
    at setState (/Users/chriscates/Projects/UniversalLoginSDK/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)
    at exports.XMLHttpRequest.handleError (/Users/chriscates/Projects/UniversalLoginSDK/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:532:5)
    at ClientRequest.errorHandler (/Users/chriscates/Projects/UniversalLoginSDK/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:459:14)
    at ClientRequest.emit (events.js:182:13)
    at ClientRequest.EventEmitter.emit (domain.js:442:20)
    at TLSSocket.socketErrorListener (_http_client.js:391:9)
    at TLSSocket.emit (events.js:182:13)
    at TLSSocket.EventEmitter.emit (domain.js:442:20) null

Versions

SilentCicero commented 5 years ago

You can switch the base param. I am updating now for infura API key support thanks.