Call to ipf through react app hanging forever

i am trying to add small json to ipfs using ipfs-http-client package with infura but on submit its hanging forever and no errors also, i have hided actual projectid and project secret

const ipfsClient = require(‘ipfs-http-client’)
const projectId = ‘1xxB’

const projectSecret = ‘7xx3a’

const auth =

'Basic ’ + Buffer.from(projectId + ‘:’ + projectSecret).toString(‘base64’)

const ipfs = ipfsClient.create({

host: ‘ipfs.infura.io’,

port: 5001,

protocol: 'https',

headers: {

    authorization: auth

  }

})

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);

    try{

    return new Promise((resolve, reject) => {

        ipfs.add(buffer, async (err, res,next) => {

            console.log(res);

            if (err) {

                console.error(err);

            } else {

                const hash = await res[0].hash;

                resolve(hash);

            }

        })

    })

}

catch(error){

    next(error)

    console.log(error)

}

Hi @komaturir and welcome to our Infura community :slight_smile:

Could you please let me know which documentation have you followed?
Please note that we have a 3 Easy Steps article which might provide you additional information → Migrate Your Files to Infura's New IPFS Service In 3 Easy Steps | Infura Blog | Tutorials, Case Studies, News, Feature Announcements

Hi Flaviu,
i dont have anything to migrate so i have followed 1 step , i can see that file created in infura but not receving hash, i have tried with firewall off also but still same issue.
Thx

Hi Flaviu,
i dont have anything to migrate so i have followed 1 step , i can see that file created in infura but not receving hash, i have tried with firewall off also but still same issue.
Thx

Hi

anyone can help me here , i really stuck

Thx

Hey @komaturir, are you following any tutorial besides the one mentioned?
I’m curious where the part with ‘new Promise’ came from.
I would review that part one more time and also try-catch block.

Please check out the following community threads here and here in regards similar issues.