-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Description
Environment
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i5-4308U CPU @ 2.80GHz
Memory: 30.14 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.8.0 - /usr/local/bin/node
Yarn: 1.9.4 - /usr/local/bin/yarn
npm: 6.4.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
Android SDK:
Build Tools: 23.0.1, 25.0.0, 26.0.1, 26.0.3, 27.0.3, 28.0.2
API Levels: 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
IDEs:
Android Studio: 3.1 AI-173.4907809
Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
npmPackages:
react: 16.4.1 => 16.4.1
react-native: 0.56.0 => 0.56.0
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
I am having this problem when trying to use ipfs-api module on React Native. I am using the ipfs-api version 24.0.1 imported to React Native with rn-nodeify version 10.0.0 with the following steps:
npm i --save rn-nodeify
npm i --save ipfs-api
Then uncomment require('crypto') in shim.js at the root of React Native project.
Then go to this file:
vi ./node_modules/isomorphic-fetch/fetch-npm-browserify.js
and add
var self = this;
before module.exports
line in the file.
Finally run:
./node_modules/.bin/rn-nodeify --hack --install
react-native link
Code
I have the following code in my project following the example for ipfs-api:
const ipfsAPI = require("ipfs-api");
...
ipfs = ipfsAPI("127.0.0.1", "5001", { protocol: "http" });
...
ipfs.files.write( // Error here
"/aaa.txt",
buffer,
{
create: true,
parents: true
},
err => {
console.log(err);
}
);
Error
When I tried running the code above in my project I get the following error:
And in the debugger I see the following:
The problem is that there is no res.trailers
element for the res
variable inside the onRes
function.
This function is located at /node_modules/ipfs-api/src/utils/send-request.js
Any thoughts is welcome, thanks for your time!