0

我不明白为什么它在启动节点应用程序时给我这个错误:

C:\Users\alien\Desktop\SCBM\Bot\SteamCardBot-master>node index.js
C:\Users\alien\Desktop\SCBM\Bot\SteamCardBot-master\utils.js:36
            for (let i = 0; i < c.sets.length; i++) {
                                       ^

TypeError: Cannot read property 'length' of undefined
    at Request.request [as _callback] (C:\Users\alien\Desktop\SCBM\Bot\SteamCard
Bot-master\utils.js:36:40)
    at Request.self.callback (C:\Users\alien\Desktop\SCBM\Bot\SteamCardBot-maste
r\node_modules\request\request.js:186:22)
    at emitTwo (events.js:125:13)
    at Request.emit (events.js:213:7)
    at Request.<anonymous> (C:\Users\alien\Desktop\SCBM\Bot\SteamCardBot-master\
node_modules\request\request.js:1163:10)
    at emitOne (events.js:115:13)
    at Request.emit (events.js:210:7)
    at IncomingMessage.<anonymous> (C:\Users\alien\Desktop\SCBM\Bot\SteamCardBot
-master\node_modules\request\request.js:1085:12)
    at Object.onceWrapper (events.js:314:30)
    at emitNone (events.js:110:20)

当我试图从 Steam API 中检索信息(' getCardsInSets ')时,它会从以下位置产生错误:

t.getCardsInSets = (callback) => {
    request("http://storage.googleapis.com/cdn.steam.tools/data/set_data.json", { json: true }, (ERR, RES, BODY) => {
        if (!ERR && RES.statusCode == 200 && BODY) {
            let c = BODY,
                d = {};
            for (let i = 0; i < c.sets.length; i++) {
                d[c.sets[i].appid] = { appid: c.sets[i].appid, name: c.sets[i].game, count: c.sets[i].true_count };
            }
            callback(null, d);
        } else {
            callback(ERR);
        }
    });
};
4

0 回答 0