我运行以下查询:
var updateTicketQuery = "UPDATE `tb_tickets` SET `status` = 0, second_gate_ip='"+_ip+"' WHERE `nationalcode` = '" + _barcode + "'";
// console.log(updateTicketQuery)
db.query(updateTicketQuery)
console.log("33")
_auth = 'disposable'
res.json({response:'barcode',success:'inTask',mode:'inTask',auth:_auth});
return false;
我的查询也执行,但是在响应时,我可以显示此错误消息(它应该返回我的res.json
):
33
/home/nodeser/node_modules/mysql/lib/protocol/Parser.js:437
throw err; // Rethrow non-MySQL errors
^
Error: Can't set headers after they are sent.
at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:369:11)
at ServerResponse.header (/home/nodeser/node_modules/express/lib/response.js:771:10)
at ServerResponse.send (/home/nodeser/node_modules/express/lib/response.js:170:12)
at ServerResponse.json (/home/nodeser/node_modules/express/lib/response.js:267:15)
at Query.db.query (/home/nodeser/routes/Ticket.js:89:37)
at Query.<anonymous> (/home/nodeser/node_modules/mysql/lib/Connection.js:525:10)
at Query._callback (/home/nodeser/node_modules/mysql/lib/Connection.js:491:16)
at Query.Sequence.end (/home/nodeser/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
at Query._handleFinalResultPacket (/home/nodeser/node_modules/mysql/lib/protocol/sequences/Query.js:139:8)
at Query.EofPacket (/home/nodeser/node_modules/mysql/lib/protocol/sequences/Query.js:123:8)