Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
js IPFS/vue.js上载错误-对象不可异步_Vue.js_Ipfs_Js Ipfs - Fatal编程技术网

js IPFS/vue.js上载错误-对象不可异步

js IPFS/vue.js上载错误-对象不可异步,vue.js,ipfs,js-ipfs,Vue.js,Ipfs,Js Ipfs,我一直在使用js ipfs(0.49.0),这很好,但我开始遇到一些问题,无论如何,我终于再次回来查看代码,连接工作正常,但当我尝试上传时,我遇到了一个新错误 对象不是异步的 我不知道这意味着什么,也不知道如何在我的代码中解决许多示例是针对react而不是vue的 任何非常适用的指针 methods: { async getIpfsNodeInfo() { try { // Await for ipfs node instance. node

我一直在使用js ipfs(0.49.0),这很好,但我开始遇到一些问题,无论如何,我终于再次回来查看代码,连接工作正常,但当我尝试上传时,我遇到了一个新错误

对象不是异步的

我不知道这意味着什么,也不知道如何在我的代码中解决许多示例是针对react而不是vue的

任何非常适用的指针

methods: {
    async getIpfsNodeInfo() {
      try {
        // Await for ipfs node instance.
        node = await ipfs
        // console.log(node)
        // Call ipfs `id` method.
        // Returns the identity of the Peer.
        const { agentVersion, id } = await node.id()
        this.agentVersion = agentVersion
        this.id = id
        // Set successful status text.
        this.status = 'Connected to IPFS 
ipfs.add
returns a single object since
ipfs@0.48.0
- you need to change:

   async saveIPFS() {
      try {
        for await (const result of node.add(this.selectedFile)) {
        
          this.fileContents = result
          this.getIPFS()
        }
      } catch (err) {
        // Set error status text.
        this.status = `Error: ${err}`
      }
    },
方法:{
异步getIpfsNodeInfo(){
试一试{
//等待ipfs节点实例。
节点=等待ipfs
//console.log(节点)
//调用ipfs`id`方法。
//返回对等方的标识。
const{agentVersion,id}=await node.id()
this.agentVersion=agentVersion
this.id=id
//设置成功状态文本。

this.status='连接到IPFS
IPFS.add
返回自
ipfs@0.48.0
-您需要更改:

async saveIPFS(){
试一试{
用于等待(node.add(this.selectedFile)的常量结果){
this.fileContents=结果
这个文件名为getIPFS()
}
}捕捉(错误){
//设置错误状态文本。
this.status=`Error:${err}`
}
},
致:

async saveIPFS(){
试一试{
this.fileContents=wait node.add(this.selectedFile)
这个文件名为getIPFS()
}捕捉(错误){
//设置错误状态文本。
this.status=`Error:${err}`
}
},
有关更多信息,请参阅博客帖子: