I use Google plus API and get this data from it and get an error while parsing this JSON data
and here is the code I use to parse this data and get error as data object is tested and work fine and hold data as it appear in past 2 images
var allIems = data.items;
for (var element in allIems) {
  document.getElementById('datafromapi').innerHTML +=
    (" , published time :" + element.published +
      " , last updated time :" + element.updated +
      ", complete url : " + element.url
    );
  var obj = element.object.attachments;
  document.getElementById('datafromapi').innerHTML +=
    (+"\nattachments of post :\n" +
      " type : " +
      obj[0].objectType +
      " ,displayName of content : " +
      obj[0].displayName +
      " ,content URL  : " +
      obj[0].url +
      " ,content data :" +
      obj[0].image.url +
      " ,content type : " +
      obj[0].image.type +
      " ,content height : " +
      obj[0].image.height +
      " ,content width : " +
      obj[0].image.width +
      "\n\n\n");
}
});
i got that error appear
Uncaught TypeError: Cannot read property 'attachments' of undefined



elementcontain theobjectproperty.element.objectis undefined. Since it's undefined, it doesn't have any attributes.objectattribute is undefined.allIemsarray.