ttezel / twit

Twitter API Client for node (REST & Streaming API)
4.31k stars 568 forks source link

Probably a silly question about debugging #446

Closed scanlonjts closed 6 years ago

scanlonjts commented 6 years ago

using Twitter.get('search/tweets', params, function(err, data) { }

how can I dump the actual data coming back so i can see what is acutally in it console.log(data) and console.log(data.toString()) dont seem to work other than printing Object

danmcgill6 commented 6 years ago

So what your trying to do is access the just the text property on the data object? try this console.log(data.statuses[0].text) or if you have more than one T.get('search/tweets', { q: 'snapchat since:2018-05-11', count: 10 }, function(err, data, response) { let statusArr = [] for(let i = 0; i < data.statuses.length; i++){ statusArr.push(data.statuses[i].text) } console.log(statusArr) })

scanlonjts commented 6 years ago

Thank you - Is there a way to get more than just that ‘text’ - is the object defined such that we can use dot notation for the list of properties?

Joe Scanlon

M: 603.459.3242 F: 1-941-296-7907 E: joe.scanlon@allstar-it.com

CONFIDENTIALITY NOTICE: This email message (including attachments) contains information which may be confidential and/or legally privileged. Unless you are the intended recipient, you may not use, copy or disclose to anyone the message or any information contained in the message or from any attachments that were sent with this email, and If you have received this email message in error, please advise the sender by email, and delete the message.

Unauthorized disclosure and/or use of information contained in this email may result in civil and criminal liability

On Jun 21, 2018, at 12:16 PM, Danny McGillicuddy notifications@github.com wrote:

let statusArr = [] for(let i = 0; i < data.statuses.length; i++){ statusArr.push(data.statuses[i].text) } console.log(statusArr) }

danmcgill6 commented 6 years ago

yes the data object sends you back an array of objects (statuses) which contain data about each individual tweet, so if you you access a status at any given index in the array you can than dot off of that and access different properties

scanlonjts commented 6 years ago

Right - got that part - but where are the different properties defined? (I am used to a stronger typed language and IDE) Joe Scanlon

M: 603.459.3242 F: 1-941-296-7907 E: joe.scanlon@allstar-it.com

CONFIDENTIALITY NOTICE: This email message (including attachments) contains information which may be confidential and/or legally privileged. Unless you are the intended recipient, you may not use, copy or disclose to anyone the message or any information contained in the message or from any attachments that were sent with this email, and If you have received this email message in error, please advise the sender by email, and delete the message.

Unauthorized disclosure and/or use of information contained in this email may result in civil and criminal liability

On Jun 21, 2018, at 12:29 PM, Danny McGillicuddy notifications@github.com wrote:

yes the data object sends you back an array of objects (statuses) which contain data about each individual tweet, so if you you access a status at any given index in the array you can than dot off of that and access different properties

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ttezel/twit/issues/446#issuecomment-399164749, or mute the thread https://github.com/notifications/unsubscribe-auth/AD-kXSklw2Wz_EXcUKNVXna8zfgM2Jb1ks5t-8nmgaJpZM4UyJ0e.

scanlonjts commented 6 years ago

I see on developer.twitter that there is a json for the a tweet status - In ‘twit’ do we have the ability to dump to console (equivalent of doing a thing.toString(). ?

Joe Scanlon

M: 603.459.3242 F: 1-941-296-7907 E: joe.scanlon@allstar-it.com

CONFIDENTIALITY NOTICE: This email message (including attachments) contains information which may be confidential and/or legally privileged. Unless you are the intended recipient, you may not use, copy or disclose to anyone the message or any information contained in the message or from any attachments that were sent with this email, and If you have received this email message in error, please advise the sender by email, and delete the message.

Unauthorized disclosure and/or use of information contained in this email may result in civil and criminal liability

On Jun 21, 2018, at 12:32 PM, Joe Scanlon joe.scanlon@allstar-it.com wrote:

Right - got that part - but where are the different properties defined? (I am used to a stronger typed language and IDE) Joe Scanlon

M: 603.459.3242 F: 1-941-296-7907 E: joe.scanlon@allstar-it.com mailto:joe.scanlon@allstar-it.com

CONFIDENTIALITY NOTICE: This email message (including attachments) contains information which may be confidential and/or legally privileged. Unless you are the intended recipient, you may not use, copy or disclose to anyone the message or any information contained in the message or from any attachments that were sent with this email, and If you have received this email message in error, please advise the sender by email, and delete the message.

Unauthorized disclosure and/or use of information contained in this email may result in civil and criminal liability

On Jun 21, 2018, at 12:29 PM, Danny McGillicuddy <notifications@github.com mailto:notifications@github.com> wrote:

yes the data object sends you back an array of objects (statuses) which contain data about each individual tweet, so if you you access a status at any given index in the array you can than dot off of that and access different properties

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ttezel/twit/issues/446#issuecomment-399164749, or mute the thread https://github.com/notifications/unsubscribe-auth/AD-kXSklw2Wz_EXcUKNVXna8zfgM2Jb1ks5t-8nmgaJpZM4UyJ0e.

scanlonjts commented 6 years ago

Never mind - I found what I was doing wrong - missing text and object in console.log -

Joe Scanlon

M: 603.459.3242 F: 1-941-296-7907 E: joe.scanlon@allstar-it.com

CONFIDENTIALITY NOTICE: This email message (including attachments) contains information which may be confidential and/or legally privileged. Unless you are the intended recipient, you may not use, copy or disclose to anyone the message or any information contained in the message or from any attachments that were sent with this email, and If you have received this email message in error, please advise the sender by email, and delete the message.

Unauthorized disclosure and/or use of information contained in this email may result in civil and criminal liability

On Jun 21, 2018, at 12:32 PM, Joe Scanlon joe.scanlon@allstar-it.com wrote:

Right - got that part - but where are the different properties defined? (I am used to a stronger typed language and IDE) Joe Scanlon

M: 603.459.3242 F: 1-941-296-7907 E: joe.scanlon@allstar-it.com mailto:joe.scanlon@allstar-it.com

CONFIDENTIALITY NOTICE: This email message (including attachments) contains information which may be confidential and/or legally privileged. Unless you are the intended recipient, you may not use, copy or disclose to anyone the message or any information contained in the message or from any attachments that were sent with this email, and If you have received this email message in error, please advise the sender by email, and delete the message.

Unauthorized disclosure and/or use of information contained in this email may result in civil and criminal liability

On Jun 21, 2018, at 12:29 PM, Danny McGillicuddy <notifications@github.com mailto:notifications@github.com> wrote:

yes the data object sends you back an array of objects (statuses) which contain data about each individual tweet, so if you you access a status at any given index in the array you can than dot off of that and access different properties

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ttezel/twit/issues/446#issuecomment-399164749, or mute the thread https://github.com/notifications/unsubscribe-auth/AD-kXSklw2Wz_EXcUKNVXna8zfgM2Jb1ks5t-8nmgaJpZM4UyJ0e.