So I'm trying to return the URL from a set of photos (using the getInterestingList) I am able to return them, but whenever I try narrow down the results and only return the source it just returns undefined in the console.
This is my code:
function getInteresting() {
var interestingStr = 'https://api.flickr.com/services/rest/?method=flickr.interestingness.getList&' + APIkey + '&per_page=20&format=json&nojsoncallback=1';
$.get(interestingStr, function (data) {
fetchLink(data);
});
}
function fetchLink(data) {
for (var i = 0; i < data.photos.photo.length; i++) {
//console.log(data.photos.photo[i].id);
var photoObject = data.photos.photo[i];
var getSizesStr = 'https://api.flickr.com/services/rest/?method=flickr.photos.getSizes&' + APIkey + '&photo_id=' + data.photos.photo[i].id + '&format=json&nojsoncallback=1';
$.get(getSizesStr, function (data) {
console.log(data.sizes.size.source); /**This is where i'm printing the result. Whenever I put in .source it returns undefined, but whenever I leave it as sizes.size it returns correctly**
});
}
What happens when I leave it as sizes.size:
[Object, Object, Object, Object, Object, Object, Object, Object, Object, Object]0: Objectheight: 75label: "Square"media: "photo"source: "https://farm4.staticflickr.com/3900/15073487900_0b89b0e136_s.jpg"url: "https://www.flickr.com/photos/janleonardo/15073487900/sizes/sq/"width: 75
when I try get the source: (desired result: undefined
Any Ideas? Thanks
edit: I'm using REst / JSON
Fixed:
What I did was add another for loop inside my GET call to the getSizes api,
$.get(getSizesStr, function (data) {
for (var x = 0; x < data.sizes.size.length; x++) {
console.log(data.sizes.size[x].source);
and it worked.