In service call i get a below response Currently i have foreach the collections and push the productID and ProductName in id and name into the options array and bind into html. Need to replace this with spread opreator with destructive object.
[
{productID:123,ProductName:'laptop',Qnty:2},
{productID:12,ProductName:'mobile',Qnty:2},
{productID:33,ProductName:'other accessories',Qnty:9},
{productID:53,ProductName:'Tv',Qnty:2},
]
//service call function block
let options =[];
console.log(response);
response.forEach(value =>{
this.options.push({
id:value.productID,
name: value.ProductName
});
});
I have trying to destructure the object.
let {productID:id,ProductName:name} = response;
But i don't know i how to insert this into options array.