I have data returned from apex as a string:
[{"Rank":1,"Points":61,"Name":"Susan Johanson","Id":"0038d00000ANPt7AAH"},{"Rank":2,"Points":23,"Name":"Barry Bronze","Id":"0038d00000ANPtcAAH"}]
I use the below to try and access the different values for each object to create my leaderboard...
export default class Tbg_leaderboard extends LightningElement {
allTBGContacts;
error;
connectedCallback(){
getRankedContacts()
.then(result => {
console.log('>>>>>>>>>>>>' + result);
this.allTBGContacts = JSON.parse(result);
console.log('>>>>>>>>>>>>' + this.allTBGContacts);
console.log('>>>>>>>>>>>>' + this.allTBGContacts[0]);
console.log('>>>>>>>>>>>>' + this.allTBGContacts[0].id);
})
.catch(error => {
this.error = error;
});
}
The console.logs seen in the .then() shows as follows:
[object Object],[object Object]
[object Object]
undefined
What do I need to do / change to be able to access these values?