Javascript 错误:Can';t在发送邮件后设置邮件头。来自调用智能合约函数
我写了一份创建简单数据库的智能合约。它包含多个函数,当我第一次点击RESTAPI时,它会给出正确的输出,但在进一步点击时,它会导致节点服务器崩溃并显示一条消息-- F:\project\blockchain\node\u modules\solc\soljson.js:1 (函数(导出,要求,模块,_文件名,_目录名){var模块;if(!module)模块=(typeof模块!=“undefined”?模块:null){};var模块overrides={};for(模块中的var键){if(模块中的 .hasOwnProperty(key)){moduleOverrides[key]=Module[key]}var环境\u IS\u WEB=typeof window==“object”;var环境\u IS\u IS\u WORKER=typeof importScripts==“function”;var环境\u IS\u IS\u NODE=type of process==“object”&&typeof require==“function”&&!ENVIRONMENT\u是WEB&!ENVIRONMENT\u是WORKER;var ENVIRONMENT\u是SHELL=!ENVIRONMENT\u是WEB&!ENVIRONMENT\u是节点&!ENVIRONMENT\u是WORKER;if(EN 环境是节点{if(!Module[“print”])Module[“print”]=函数print(x){process[“stdout”].write(x+“\n”)};if(!Module[“printErr”])Module[“printErr”]=函数printErr(x){process[“stderr”].write (x+“\n”)};var nodeFS=require(“fs”);var nodePath=require(“path”);Module[“read”]=函数读取(文件名,二进制){filename=nodePath“normalize”;var ret=nodeFS[“readFileSync”](文件名) 错误:发送邮件后无法设置邮件头。 在ServerResponse.OutgoingMessage.setHeader(_http_outgoing.js:344:11) 在ServerResponse.header(F:\project\blockchain\node\u modules\express\lib\response.js:725:10) 在ServerResponse.send(F:\project\blockchain\node\u modules\express\lib\response.js:170:12) 位于ServerResponse.json(F:\project\blockchain\node\u modules\express\lib\response.js:256:15) 在F:\project\blockchain\BlockchainDB\users\userFunction.js:37:47 在F:\project\blockchain\node\u modules\web3\lib\web3\filter.js:120:21 at Array.forEach(本机) 在F:\project\blockchain\node\u modules\web3\lib\web3\filter.js:119:32 at Array.forEach(本机) 在Object.onMessage[作为回调](F:\project\blockchain\node\u modules\web3\lib\web3\filter.js:117:22) 我的api代码Javascript 错误:Can';t在发送邮件后设置邮件头。来自调用智能合约函数,javascript,node.js,express,ethereum,solidity,Javascript,Node.js,Express,Ethereum,Solidity,我写了一份创建简单数据库的智能合约。它包含多个函数,当我第一次点击RESTAPI时,它会给出正确的输出,但在进一步点击时,它会导致节点服务器崩溃并显示一条消息-- F:\project\blockchain\node\u modules\solc\soljson.js:1 (函数(导出,要求,模块,_文件名,_目录名){var模块;if(!module)模块=(typeof模块!=“undefined”?模块:null){};var模块overrides={};for(模块中的var键){if(
module.exports.creation=function(req,res){
var user_id = req.params.user_id || req.body.user_id;
var currency = req.params.user_id || req.body.currency ;
if(user_id == undefined || currency == undefined){
res.status(500).json({status:false,errors:"Empty parameters"});
}else{
isaccount().then(function(accountNumber){
if(accountNumber!=null){
var timestamp = Date.now();
var result = contract.createUser.sendTransaction(user_id,currency,accountNumber,timestamp,{from:web3.eth.coinbase,gas:600000});
var event = contract.CreatedUser(function(error, result) {
if (!error){
if(result.args.userId!= undefined && result.args.accountId!= undefined && result.args.categoryId!= undefined){
logger.info("user created with id :"+result);
res.status(200).json({status:true,data:{iduser:result.args.userId,accountId:result.args.accountId,created_at:timestamp}});
}else{
logger.info("user creation have problem :");
res.status(500).json({status:false,errors:"no response"});
}
}else{
logger.error(error);
res.status(500).send(false);
}
});
}else{
logger.debug("Problem in accountNumber generation");
res.status(500).send(false);
}
});
}
}
请帮我解决这个问题
提前感谢尝试对所有的
res.status()
调用使用return
语句。因此,即使响应状态设置为某个值,它也会在之后的某个位置再次获得res.status()