Hyperledger node.js无法分析null

Hyperledger node.js无法分析null,node.js,hyperledger,hyperledger-composer,Node.js,Hyperledger,Hyperledger Composer,有人能帮助解决HL Composer上出现的错误吗? 错误内容:错误:语法错误:无法分析null:意外标记(377:39) 第377行是:let exists=等待accounts.exists(element.destinationAcc) 这是javascript开发人员犯的一个相当标准的错误,与hyperledger composer完全无关 您正试图在尚未声明为async的方法内执行wait。但是,即使将关键字async添加到在forEach声明中声明的方法中,由于forEach的工作方

有人能帮助解决HL Composer上出现的错误吗? 错误内容:错误:语法错误:无法分析null:意外标记(377:39) 第377行是:let exists=等待accounts.exists(element.destinationAcc)


这是javascript开发人员犯的一个相当标准的错误,与hyperledger composer完全无关

您正试图在尚未声明为
async
的方法内执行
wait
。但是,即使将关键字
async
添加到在
forEach
声明中声明的方法中,由于forEach的工作方式,它仍然无法工作

因此,对于您来说,解决方案是,不要使用数组的forEach方法来尝试运行包含
wait
的匿名函数。使用另一种方法来迭代allTransactions数组,例如for循环

        
        let accounts = await getAssetRegistry(ns + '.Account');
        let transactions = await getAssetRegistry(ns + '.Transactions');

        let allTransactions = await query('pendingTransactions');
        let allAccounts = await accounts.getAll();
      
        if (allTransactions.length() > 0) {
            allTransactions.forEach(element => {
                if (element.status == 'PENDING') {
                    
                    let exists = await accounts.exists(element.destinationAcc);
                   
                    if (exists) {
                        
                        let destAcc = await allAccounts.find(element.destinationAcc);