我在从MYSQL数据库解析交易令牌时遇到轻微错误
/bot/node_modules/mysql/lib/protocol/Parser.js:77 throw err; // Rethrow non-MySQL errors ^ TypeError: undefined is not a function at Query._callback (/bot/bot_source.js:974:32) at Query.Sequence.end (/bot/node_modules/mysql/lib/protocol/sequences/Sequence.js:96:24) at Query._handleFinalResultPacket (/bot/node_modules/mysql/lib/protocol/sequences/Query.js:144:8) at Query.EofPacket (/bot/node_modules/mysql/lib/protocol/sequences/Query.js:128:8) at Protocol._parsePacket (/bot/node_modules/mysql/lib/protocol/Protocol.js:280:23) at Parser.write (/bot/node_modules/mysql/lib/protocol/Parser.js:73:12) at Protocol.write (/bot/node_modules/mysql/lib/protocol/Protocol.js:39:16) at Socket.<anonymous> (/bot/node_modules/mysql/lib/Connection.js:96:28) at Socket.emit (events.js:107:17) at readableAddChunk (_stream_readable.js:163:16)
代码:
if (body.response.trade_offers_received) {
body.response.trade_offers_received.forEach(function(offer) {
if (offer.trade_offer_state == 2) {
mysqlConnection.query('SELECT * FROM `users` WHERE `steamid`="'+offer.steamid_other+'"',function(usrerr,usrres,usrfields){
if(usrres.length==0){
console.log('user does not exist in database: '+offer.steamid_other);
return;
}
var tlink=usrres[0].tlink;
if (tlink == '') {
console.log('no trade link in db for user: '+offer.steamid_other);
return;
}
var tokenStr = tlink.split('token=', 2);
var token = tokenStr[1];
offers.getHoldDuration({
partnerSteamId:offer.steamid_other,
accessToken:token,
}, function (holderr,duration) {
if(holderr){
console.log('holdduration error: '+holderr);
return;
}
if ((duration.my != 0) || (duration.their != 0)) {
myconsolelog('Trade declined because either the bot or the person sending the offer has a trade period '+offer.tradeofferid);
offers.declineOffer({
tradeOfferId: offer.tradeofferid
});
declinedoffer=true;
if(duration.their!=0){
var unixtime = Math.round(new Date().getTime() / 1000.0);
var messagedata={to:offer.steamid_other,msg:'Trade declined. You can not instantly trade because you are not using trade confirmations through the mobile authenticator.',time:unixtime,type:'tradehold'};
io.emit('message',messagedata);
}
return;
} }); });
`
我希望在&#34; token =&#34;之后检索交易令牌,但它似乎在途中遇到错误,
我会喜欢任何建议。