Goalyan
Goalyan

Reputation: 13

"TypeError: RequestInit: duplex option is required when sending a body" trying to upload metadata and store it on IPFS

When I try to run the following code, I have this error: "TypeError: RequestInit: duplex option is required when sending a body"

I am trying to upload metadata and store it on IPFS.

My code is:

async function run() {
const { create } = await import('ipfs-http-client');
const ipfs = await create();

// we added three attributes, add as many as you want!
const metadata = {
    path: '/',
    content: JSON.stringify({
        name: "My First NFT",
        attributes: [
        {
            "trait_type": "Peace",
            "value": "10" 
        },
        {
            "trait_type": "Eternity",
            "value": "100"
        },
        {
            "trait_type": "Web3",
            "value": "1000"
        }
        ],
       
        // update the IPFS CID to be your image CID
        image: "QmT9R4R2vrSy824zqB8tFnFngW5FaFAT54ivZTt3nPR32Q",
        description: "So much memories!"
    })
    
};

const result = await ipfs.add(metadata);
console.log(result);

process.exit(0);

}

run();

Please, tell me If I have to add something to my code and where. Thank you very much!

Upvotes: 0

Views: 74

Answers (0)

Related Questions