Home > OS >  how to do to retrieve person.photos[0].default?
how to do to retrieve person.photos[0].default?

Time:02-16

I tried to retrieve the variable Default from json of people api but it doesn't work with "default" . how to do it ? thank you for your answer

see my test script below, please (last line at bottom)

var person = People.People.get('people/'   accountId, {personFields: 'names,photos,phoneNumbers,addresses,birthdays,sipAddresses,organizations,genders'});
  //** var val_displayName_P = person.names[0].displayName;
   var val_photoUrl = person.photos[0].url.replace("=s100","=s128");
  var primary_BLN  = person.photos[0].metadata.primary;
  var default_BLN  = person.photos[0].default;

CodePudding user response:

JSON is case sensitive, try person.photos[0].Default.

CodePudding user response:

Seems like it is not returning default field in JSON response when a particular accountID contains user-provided photo(default : false), looks like a bug to me, not sure.

In case of User-provided photo, this is the log i am getting :-

enter image description here

And in case of default photo:-

enter image description here

Maybe that's why execution is breaking at last line.

If this is the case, for now you can try this :-

const photo= person.photos[0]
var default_BLN = photo.hasOwnProperty('default') ? photo.default :  false;

Reference:

Photo

  • Related