I am attempting to include variables into the existing JSON data that is received from an API whenever a user clicks on the add button. However, I encountered this error message:
Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays
The data is stored in a variable called pageList
.
Below is an example of how the data is returned from the server:
DATA
[{"id":5,"referenceId":1189,"firstName":"Dan","lastName":"Daniels","orders":[{"id":109,"meals":[{"id":47,"name":"Fried Rice","description":"This is a very sweet meal","image":"","mealType":"LUNCH","unitPrice":-20,"status":"ENABLED"}],"serveDate":"2019-07-11 00:00:00"}]}]
FUNCTION
AddtoList() {
const meals = {'id': '0','name': 'New Food', 'unitPrice':'5'}
this.pageList.push({
'firstName': 'Jackson',
'lastName': 'Jack',
orders: {meals: meals}
})
}