代码:
checkMongoQuery(mqueries,function(data){
message.mongo=data;
checkMySqlQuery(temp,function(data){
if(data.msg==gloabl_vars.messages.success){
message.msg==gloabl_vars.messages.success;
}
else{
message.msg==gloabl_vars.messages.failed;
}
message.mysql=data;
result(null,message);
});
});
首先将调用checkMongoQuery函数,然后在两者均成功执行时执行checkMySqlQuery函数,它将返回result方法。在结果方法中,它抛出一个错误,指出“重新引发非mysql错误”。 请让我知道上面代码中的问题在哪里。预先感谢。
错误跟踪:
E:\nodeapi\node_modules\mysql\lib\protocol\Parser.js:80
throw err; // Rethrow non-MySQL errors
^
Error: Can't set headers after they are sent.
at validateHeader (_http_outgoing.js:491:11)
at ServerResponse.setHeader (_http_outgoing.js:498:3)
at ServerResponse.header (E:\nodeapi\node_modules\express\lib\response.js:76
7:10)
at ServerResponse.send (E:\nodeapi\node_modules\express\lib\response.js:170:
12)
at ServerResponse.json (E:\nodeapi\node_modules\express\lib\response.js:267:
15)
at E:\nodeapi\api\controllers\appController.js:96:11
at E:\nodeapi\api\models\appModel.js:141:10
at Query.<anonymous> (E:\nodeapi\api\models\appModel.js:193:9)
at Query.<anonymous> (E:\nodeapi\node_modules\mysql\lib\Connection.js:502:10
)
at Query._callback (E:\nodeapi\node_modules\mysql\lib\Connection.js:468:16)
[nodemon] app crashed - waiting for file changes before starting...