I am trying to pull data from an array, but I just want to pull the id field, not the name field as well. Using Json Stringify I can log the result in the console, here is the code and the result:
Console log:
console.log(JSON.stringify(this.selectedCustomers));
Result:
[{"id":1,"name":"John"},{"id":2,"name":"Jane"}]
The desired result should be this: [1,2]
I tried the following thinking it would filter the result:
console.log(JSON.stringify(this.selectedCustomers.id));
But I got the following error message: "Property 'id' does not exist on type 'any[]'"
How do I strip out the name field and just pull the ids? If anyone can tell me what i'm missing or how to fetch the id only it would be highly appreciated! Thanks!