Hello community,
My goal is to add content to IPFS using JS
Here is my code
const axios = require('axios');
const pinJsonToIPFS = async function () {
const buffer = Buffer.from('What a wonderful day');
try {
const result = await axios.post(
`domain/cluster/add`,
buffer
, {
headers: {
'Content-Type': `multipart/form-data; boundary=${undefined}`,
}
});
console.log(result)
return result.data;
} catch (err) {
console.log(err);
}
}
const getJsonFromIPFS = async function (hash) {
let result = await axios.get(`http://domain/ipfs/${hash}`);
return result.data;
};
(async () => {
const hash = await pinJsonToIPFS();
// console.log(hash);
})()
The response data is always empty. How I could process adding content?