Armax / Pokemon-GO-node-api

Pokemon GO api node.js library
MIT License
875 stars 198 forks source link

Fix error/crash when xdat is undefined #170

Closed LocutusOfBorg closed 6 years ago

LocutusOfBorg commented 8 years ago

example.js:116 console.log(status[xdat.Status]); ^ TypeError: Cannot read property 'Status' of undefined

LocutusOfBorg commented 8 years ago

it is not happening everytime, but so often in the last few days, probably the server is not answering correctly due to highload, and the example code crashes

BlackRosie commented 8 years ago

this seems to be coming back undefined every attempt now anyone else ?

LocutusOfBorg commented 8 years ago

it really depends on the server I guess

BlackRosie commented 8 years ago

maybe i was put on a shadow ban, but this seems to return undefined and never catches the encountered pokemon.

Vlek commented 8 years ago

The Niantic servers aren't going to send you what you want when you expect it every time. Really, your code should be able to handle these error cases. So, in this case, instead of assuming you're going to get xdat.Status, you should first check whether you have it before using it. This is just good practice in general regardless of one's project.