My node application just spat out this error, which I don't understand:
trendData && trendData.forEach(function(trendDataItem){
^
TypeError: Object Error: HTTP Error undefined: undefined has no method 'forEach'
at /home/myapp/node/dataSource/enabled/twitterTrending.js:9:36
The && operator should be preventing any undefined
values of trendData
reaching the second part of the expression, but it seems not to have worked. My understanding of node.js is that my code doesn't have to concern itself with multi-threading issues, so I assume there's no chance that the value of trendData
changed between the evaluation of the first part of the expression and the second.
The trendData
value is passed in from a callback made by a twitter library, source code here, the line that is failing is inside the 'callback' function, from what I can see it should be the result of JSON.parse
if everything worked, otherwise it will contain failure information.
Anybody have a clue what's going on?