I am building an application that uses a lot of different sources (and APIs) to build an auto-updating blog aggregate. I can access all the data I want using Tumblr's API and can see the data I want using Twitter's API, however I am storing all of the data into my own object so I can reference it more easily.
The problem being that Twitter returns an Array that is seemingly unnamed whereas Tumblr returns a static object with sections that I can pull through. Here is a screenshot:
As you can see the the object indexed as 1 is seemingly an unnamed Array (this is the data I get back from Twitter). Now, the problem lies when I am pulling through all the information to extract the pertinent timestamps for display order. Here is my code:
for(var i=0;i<blogs.content.length;i++){
if(!blogs.content[i].length){
for(var e=0; e<blogs.content[i].response.posts.length; e++){
blogs.dates.push(blogs.content[i].response.posts[e].timestamp);
}
} else {
for (var e = 0; e<blogs.content[i].length; e++){
//console.log( blogs.content[i].e.text );
}
}
}
within the else statement there is a For Loop, for which I am trying to pull through the data I receive from Twitter. However, I cannot for the life of me figure out how to access the data since I am looking at an unnamed Array.
Any ideas on how to properly access the information?
I figured out the issue, it was a simple syntax problem that I had to wrap my head around. Here is the code I used to fix it:
for(var i=0;i<blogs.content.length;i++){
if(!blogs.content[i].length){
for(var e=0; e<blogs.content[i].response.posts.length; e++){
blogs.dates.push(blogs.content[i].response.posts[e].timestamp);
}
} else {
for (var e = 0; e<blogs.content[i].length; e++){
console.log( blogs.content[i][e].text );
}
}
}