Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object.keys called on non-object #11

Closed
kaosdynamics opened this issue Oct 8, 2011 · 5 comments
Closed

Object.keys called on non-object #11

kaosdynamics opened this issue Oct 8, 2011 · 5 comments

Comments

@kaosdynamics
Copy link

Using this context:
NTwitter 0.2.7 on NodeJS 0.4.12 on 2.6.35.14-97.fc14.x86_64

NodeJS server crashes on

/usr/local/node/lib/node_modules/ntwitter/lib/twitter.js:204
Object.keys(params).forEach(function(item) {
^
TypeError: Object.keys called on non-object
at Function.keys (native)
at Twitter.stream (/usr/local/node/lib/node_modules/ntwitter/lib/twitter.js:204:10)
at s (**********************)
at Query. (/usr/local/node/lib/node_modules/mysql/lib/client.js:108:11)
at Query.emit (events.js:61:17)
at Query._handlePacket (/usr/local/node/lib/node_modules/mysql/lib/query.js:51:14)
at Client._handlePacket (/usr/local/node/lib/node_modules/mysql/lib/client.js:312:14)
at Parser. (native)
at Parser.emit (events.js:64:17)
at /usr/local/node/lib/node_modules/mysql/lib/parser.js:71:14

I "fixed it" using the old code...
if (Array.isArray(params)) {
params.forEach(function (item) {
params[item] = params[item].join(',');
});
}

Any idea of what's goin' on?

@AvianFlu
Copy link
Owner

AvianFlu commented Oct 8, 2011

Can you show me your code? I suspect that your params are [ ], [ ] when they may need to be { track: [ ], follow: [ ] } or something similar.

The old code may not throw for you, but when it was tested, it wasn't successfully retrieving any tweets, either.

@kaosdynamics
Copy link
Author

twitter.stream("user", function(stream)
{
stream.on("data", function(data)
{
if(data.text && data.user.screen_name && data.user.profile_image_url, data.created_at)
{
client.emit("newtweet",
{id: data.id, title: data.text, user_name:data.user.screen_name, user_img:data.user.profile_image_url, time: data.created_at} );
}
});
});

@AvianFlu
Copy link
Owner

AvianFlu commented Oct 8, 2011

I understand - you aren't passing specific params, and undefined doesn't have any keys. I'll add a check for this in a moment, thanks for pointing this out!

@kaosdynamics
Copy link
Author

Perfect! thank you! ;)

@AvianFlu
Copy link
Owner

AvianFlu commented Oct 8, 2011

Published in ntwitter@0.2.7-1. Thanks again!

@AvianFlu AvianFlu closed this as completed Oct 8, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant