So, Im trying to deal with an API. i successful load the json(which is an array of objects) in my browser like the following
0:
source: {id: null, name: "Protothema.uk"}
author: "james bond"
title: " A TITLE"
description: "A DESCRIPTION"
__proto__: Object
my code
$.getJSON("http://newsapi.org/v2/top-headlines?country=uk&category=health&apiKey=MYAPIKEY", function(data){
//console.log(data);
$.each(data,function(index,value){
console.log(value);
console.log(value[0]);
console.log(value[0].title)//Cannot read property 'title' of undefined
});
});
when i try to print the whole index like console.log(value[0]);
i successfully get all the objects of the index 0.
but when i try to print a specific value of key like console.log(value[0].title)
i get Cannot read property 'title' of undefined
im stuck for hours, what im doing wrong?