I'm facing a challenge with the Google People API where I have a promise and need to convert parts of the data into an array. However, I am struggling to create child elements within the array.
let newArray = [];
for (var i = 0; i < obj.length; i++) {
newArray.push(obj[i].requestedResourceName);
for (var j = 0; j < obj[i].person.names.length; j++) {
if (obj[i].person.names[j].metadata.source.type === 'CONTACT') {
newArray[i].push(obj[i].person.names[j]);
}
}
}
The problem I'm encountering is: Error: Uncaught (in promise): TypeError: newArray[i].push is not a function