SilentCicero / ipfs-mini

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

Bug "response.setEncoding is not a function" #3

Closed RamiroMoreira closed 7 years ago

RamiroMoreira commented 7 years ago

Issue Type

Description

I get "response.setEncoding is not a function" every time i call a ipfs method , i'm using infura the way it says in the documentation.

modules.js?hash=9195ecd…:43510 Uncaught TypeError: response.setEncoding is not a function at module.exports.responseHandler (modules.js?hash=9195ecd…:43510) at module.exports.EventEmitter.emit (modules.js?hash=9195ecd…:12517) at module.exports. (modules.js?hash=9195ecd…:33742) at module.exports.EventEmitter.emit (modules.js?hash=9195ecd…:12514) at module.exports.Response.handle (modules.js?hash=9195ecd…:33970) at XMLHttpRequest.xhr.onreadystatechange (modules.js?hash=9195ecd…:33754)

I think it's some cross origin problem, but i don't know how to fix it.

SilentCicero commented 7 years ago

@RamiroMoreira that doesn't seem to be a call we make on the response object setEncoding. Can you describe a little more about how you are using ipfs-mini with infura.

Nodejs or browser etc.

RamiroMoreira commented 7 years ago

I'm using meteor, node v4.8.1. with all the code on client side, i copy exactly the example.

SilentCicero commented 7 years ago

I believe this is what it is (although I could be wrong): http://stackoverflow.com/questions/20965055/using-the-xmlhttprequest-object-in-a-meteor-package

Meteor uses it's own HTTP request module. We use the one injected by the browser. This may cause problems because the setEncoding function does not exist as it is being overridden by meteor.

I would recommend moving away from frameworks like Meteor, where auto code injection and code magic are not a problem. React/Vue/Preact are great, would reduce problems like this.

Anyway, sorry I cant be much help here.

You may want to try just using the /dist/ipfs.min.js file, and throwing that in your Meteor build. Use window.IPFS. See what the result is with that.

RamiroMoreira commented 7 years ago

yeah, i think you are right, becouse i now can make get to the api with meteor http module and works fine. I'm still having problems to add a file using post, but i'm working on that. Thanks a lot!

SilentCicero commented 7 years ago

Closing this issue for now.