Hello everyone,
I’m developing a dapp using node.js and IPFS, where the user can select a file from a web page and upload it to IPFS. My problem is that I can’t connect my app to the IPFS API, even though the daemon is running correctly on my machine.
Every command from cli works correctly as well, but if I try to replicate, for instance, the “add” command on my app, it doesn’t work.
The error I get when I use the create() command is:
FetchError: request to http://localhost:5001/api/v0/version failed, reason: connect ECONNREFUSED ::1:5001
I’ve already allowed CORS requests but nothing changed.
Could someone help me, please? I really do not know what to do anymore
The node is running correctly (I can access it by 127.0.0.1:5001 and I can upload files with cli commands as well). I’ve already tried to turn off Windows firewall, use another network but nothing changed.
The code I’m using is the following:
var ipfs = ipfsAPI(‘localhost’, ‘5001’, {protocol: ‘http’});
console.log(‘Your IPFS node is ready.’);
ipfs.version((err, version) => {
if(err) {
console.error(‘Error getting the IPFS version’, err);
return;
}
console.log('version: ',version.version)
});
Previously I tried with const ipfs = await create(); but with the same result.