i am trying to add small json to ipfs using ipfs-http-client package , i can see ipfs running as daemon in local machine without any issues and alsoi am able to add string to ipfs through linux console but same i am trying from react app but its not working
const ipfsClient = require(‘ipfs-http-client’)
i have tried below two ways to create ipfs object both are returning object so no issues
const ipfs = ipfsClient.create ({
host: 'localhost',
port: 5001,
rotocol: 'http'
})
const ipfs = ipfsClient.create('/ip4/0.0.0.0/tcp/5001');
Problem is i am not able to add file to ipfs with below call , its hanging forever
obj[address] = {
fullname,
status: "Active"
}
let buffer = Buffer.from(JSON.stringify(obj));
console.log(buffer);
console.log(ipfs);
return new Promise((resolve, reject) => {
ipfs.add(buffer, async (error, response) => {
if (error) {
console.error(error);
} else {
const hash = await response[0].hash;
resolve(hash);
}
})
})