无法将undefined或null转换为对象帮助我

时间:2017-10-28 19:10:32

标签: javascript php node.js null undefined

我的index.js中有代码,当我通过node index.js

运行它时
Utils.getCardsInSets((ERR, DATA) => {
if (!ERR) {
    allCards = DATA;
    console.log("Card data loaded. [" + Object.keys(DATA).length + "]");
} else {
    console.log("An error occurred while getting cards: " + ERR);
}
});

而且我有错误:

/root/cardsteambot/index.js:38
    console.log("Card data loaded. [" + Object.keys(DATA).length + "]");
                                               ^

TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at Utils.getCardsInSets (/root/cardsteambot/index.js:38:52)
at Request.request [as _callback] (/root/cardsteambot/utils.js:41:13)
at Request.self.callback (/root/cardsteambot/node_modules/request/request.js:186:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request.<anonymous> (/root/cardsteambot/node_modules/request/request.js:1163:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage.<anonymous> (/root/cardsteambot/node_modules/request/request.js:1085:12)

我该如何修理呢。

0 个答案:

没有答案