Accepted answer

you can convert your pushToIPFS to be a promise instead of a callback, and just resolve it when the callback is fired.

pushToIPFS = (e) => {
    return new Promise((resolve, reject) => {
          ipfs.add(this.state.buffer, (err, ipfsHash) => {

And since its a promise you can use async/await.

AddMyStuff = async (e) => {
        const ipfsHash = await this.pushToIPFS();
        //you have your ipfsHash defined, you can pass it to your other methods

Related Query

More Query from same tag