ipfs.cat(cid) in node js gives error "Error: Invalid version, must be a number equal to 1 or 0 at Function.validateCID"

ipfs.cat(cid) in node js gives error "Error: Invalid version, must be a number equal to 1 or 0 at Function.validateCID"

我正在使用 ipfs-http-client 模块。

This is my script

async function main() {

const ipfs_client = require('ipfs-http-client');
const client = ipfs_client({recursive: false});


async function addFile(file_data) {
    const cid = function (data) {

        return client.add(data).then(cid =>{return cid;}).catch(err=>{
            console.log(err)})
    }
    const real_cid = cid(file_data).then(result=>{return result}).catch(err=>{console.log(err)});
    return real_cid;
}

const sendFileToNet = async (file) => {
    return await addFile(file);
}
async function getFile(cid){

//error occurs here
    for await (const chunk of client.cat(cid)) {
        console.info(chunk)
    }
    return content;
}

const getFileFromNet = async()=>{
    return await getFile();
}
getFileFromNet("QmU77sHBUuCT12324e9Re59bNHekpKg1PdCpiVAj3MFLiH").then(r => console.log(r));
module.exports = {sendFileToNet, getFileFromNet

};

}

main();

(node:22889) UnhandledPromiseRejectionWarning: Error: Invalid version, must be a number equal to 1 or 0 at Function.validateCID (/home/chipego/Documents/MedChain/node_modules/ipfs-http-client/node_modules/cids/src/index.js:346:13) at new CID (/home/chipego/Documents/MedChain/node_modules/ipfs-http-client/node_modules/cids/src/index.js:174:9) at Object.cat (/home/chipego/Documents/MedChain/node_modules/ipfs-http-client/src/cat.js:16:48) at cat.next () at getFile (/home/chipego/Documents/MedChain/logic/ipfs_submit_controller.js:23:26) at getFileFromNet (/home/chipego/Documents/MedChain/logic/ipfs_submit_controller.js:30:22) at main (/home/chipego/Documents/MedChain/logic/ipfs_submit_controller.js:32:5) at Object. (/home/chipego/Documents/MedChain/logic/ipfs_submit_controller.js:39:1) at Module._compile (internal/modules/cjs/loader.js:1063:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) (Use node --trace-warnings ... to show where the warning was created) (node:22889) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2) (node:22889) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with

您的 getFile 函数接受一个参数。您在 getFileFromNet 中调用它但没有传递参数。