0

I can´t figure why it is giving me this error while starting the node app:

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)

While I am trying to retrieve the info ('getCardsInSets') from Steam API it produces an error from :

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);
        }
    });
};
  • 1
    Are you sure the JSON is parsing properly? When I check out that API link I get the following error: "SyntaxError: JSON.parse: end of data after property value in object at line 1 column 677017 of the JSON data" – Andy Nov 19 '17 at 16:28
  • What are the contents of the `BODY` variable? – Get Off My Lawn Nov 19 '17 at 16:30
  • You can see from the .json file itself that it's not properly formed. It ends with `, {"added": 13`. – Kirk Larkin Nov 19 '17 at 16:33

0 Answers0