I'm using the following code for my Google Sheet Apps Script which autocompletes an input field with my Google Contacts. It works with the text, but I can't make it fetch profile images as well. This the code I'm using, and as far as I understand the null value is where the img should go, but I'm unable to pass it without ruining the whole thing. Could you please help me?
// Autocomplete for phone numbers
function getAvailableTags1() {
const contacts = People.People.Connections.list("people/me", {
personFields: "names,photos,phoneNumbers,nicknames",
pageSize: 1500
}).connections;
const res = contacts.reduce((ar, c) => {
if (c.hasOwnProperty("names") && c.hasOwnProperty("photos") && c.hasOwnProperty("nicknames") && c.hasOwnProperty("phoneNumbers")) {
const name = c.names[0].displayNameLastFirst;
const img = c.photos[0];
const number = c.phoneNumbers[0].value;
const nick = c.nicknames[0].value + " (" + number + ")";
ar.push([
name+`
`+number+`
`+nick]);
}
return ar;
},
[]);
var dynamicOptions = {};
res.forEach(function(v) {
dynamicOptions[[v]] = null
});
Logger.log(dynamicOptions);
return dynamicOptions;
}