Ipfs.add() missing return value (hash)

Hey guys,

I started to learn IFPS and connected via javascript with this code:

const ipfsClient = require('ipfs-http-client');
const projectId = '...';
const projectSecret = '...';
const ipfs = ipfsClient({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' })
const auth = 'Basic ' + Buffer.from(projectId + ':' + projectSecret).toString('base64')

const client = ipfsClient({
  host: 'ipfs.infura.io',
  port: 5001,
  protocol: 'https',
  apiPath: '/api/v0/',
  headers: {
    authorization: auth

Next I added a base64 encoded string buffer:

await client.add(buf, (err, result) => {

I expected as output the hash from infura but the console log is empty.
The file is added successful to ipfs.

Has anyone had a similar problem? I have also been in contact with support. You can see RC 200 in the log.

Thanks in advance,

Finally I solved it:

For everyone who has the same issue:

let result = client.add(buf)
  .then(result => {
1 Like

Hi @creatorbox, and welcome to the Infura community! Thank you for posting your solution so any others who run into this can reference it!