代码:
console.log("NOW()")
console.log(new Date())
connection.query(fetchActiveRequests, values, function(err, result_requests) {
console.log("==================== getActiveRequestsIfAny")
console.log(result_requests)
var result_requests_length = result_requests.length;
for (var i = 0; i < result_requests_length; i++) {
result_requests[i].current_time = result_requests[i].request_made_on
.toISOString()
.replace(/T/, ' ')
.replace(/\..+/, '');
result_requests[i].time_left = 60;
}
错误:
undefined
/var/www/html/taxinew/ilmp-server/app-server/node_modules/mysql/lib/protocol/Parser.js:80
throw err; // Rethrow non-MySQL errors
^
TypeError: Cannot read property 'length' of undefined
at Query._callback (/var/www/html/taxinew/ilmp-server/app-server/routes/ride_parallel_dispatcher.js:3555:58)
at Query.Sequence.end (/var/www/html/taxinew/ilmp-server/app-server/node_modules/mysql/lib/protocol/sequences/Sequence.js:88:24)
at Query.ErrorPacket (/var/www/html/taxinew/ilmp-server/app-server/node_modules/mysql/lib/protocol/sequences/Query.js:90:8)
at Protocol._parsePacket (/var/www/html/taxinew/ilmp-server/app-server/node_modules/mysql/lib/protocol/Protocol.js:279:23)
at Parser.write (/var/www/html/taxinew/ilmp-server/app-server/node_modules/mysql/lib/protocol/Parser.js:76:12)
at Protocol.write (/var/www/html/taxinew/ilmp-server/app-server/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket.<anonymous> (/var/www/html/taxinew/ilmp-server/app-server/node_modules/mysql/lib/Connection.js:103:28)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
答案 0 :(得分:0)
result_requests
是undefined
。可能你得到一个错误,并且 您没有处理代码中的错误。