0

I am unable to figure out what mistake i have done in the code

Whenever i am calling api, ipfs.add('hello') returns [object AsyncGenerator]

https://gateway.ipfs.io/ipfs/[object AsyncGenerator]

  const addFile = async () => {
            const Added = await ipfs.add('hello');
            return Added;
        }
        const fileHash = await addFile();
        return fileHash;

1 Answer 1

3

You can iterate over the result of .add() like so:

for await (const item of Added) {
  console.log('item', item)
} 

item { path: 'QmWfVY9y3xjsixTgbd9AorQxH7VtMpzfx2HaWtsoUYecaX',
cid: CID(QmWfVY9y3xjsixTgbd9AorQxH7VtMpzfx2HaWtsoUYecaX), size: 13 }

Sign up to request clarification or add additional context in comments.

4 Comments

how to create folder in ipfs and upload image?
Hi Ishwar, you can learn how to create a folder and upload images in this guide: proto.school/#/mutable-file-system
i gone through the url you shared above , i used those commands from command line and wroks fine, but when i am trying to implement same thing in node.js i am getter’s some error, will you help me out with some source code in nodejs for creating folder and uploading images in ipfs
@IshwarChandra yes, but please file new question - is very different than original one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.