RIAEvangelist / node-dominos-pizza-api

This is a node.js wrapper for the dominos pizza apis
MIT License
548 stars 132 forks source link

TypeError: Cannot read property 'ID' of undefined #63

Closed TheConceptionist closed 7 years ago

TheConceptionist commented 7 years ago

I'm trying to use the doc demonstration to log a menu, but upon using the following code:

const dominos = require("dominos");
var theStore = new dominos.Store(); 
theStore.ID = 7056; 
theStore.getMenu(
    function(menuData) {
        console.log(menuData)
    }
)

I get a TypeError, which is printed in the title of this issue. This is the error stack:

TypeError: Cannot read property 'ID' of undefined
    at new Store (/home/ubuntu/workspace/node_modules/dominos/src/Store.js:10:25)
    at eval (eval at <anonymous> (/home/ubuntu/workspace/dominos.js:84:146), <anonymous>:1:17)
    at Client.mybot.on.e (/home/ubuntu/workspace/dominos.js:84:141)
    at emitOne (events.js:96:13)
    at Client.emit (events.js:188:7)
    at MessageCreateHandler.handle (/home/ubuntu/workspace/node_modules/discord.js/src/client/websocket/packets/handlers/MessageCreate.js:9:34)
    at WebSocketPacketManager.handle (/home/ubuntu/workspace/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:104:65)
    at WebSocketManager.eventMessage (/home/ubuntu/workspace/node_modules/discord.js/src/client/websocket/WebSocketManager.js:225:31)
    at WebSocket.ws.onmessage (/home/ubuntu/workspace/node_modules/discord.js/src/client/websocket/WebSocketManager.js:83:37)
    at WebSocket.onMessage (/home/ubuntu/workspace/node_modules/ws/lib/WebSocket.js:442:14)

(If some of that looks unfamiliar, I'm using another package in conjunction with this.)

RIAEvangelist commented 7 years ago

I'll take a look

mkl64 commented 7 years ago

You need to pass in an anonymous object with ID filled out. Look at the Store constructor. It will look something like this:

var myStore = new pizzapi.Store( { ID: 7111 } );