Having trouble with Angular and TypeScript. Need to fetch a GET API from Spring where the return variable is Page, but the JSON structure looks like this:
"content": [
{
"id": 1,
"category": "TSHIRT",
"model": "cool pants",
"mark": "ADIDAS",
"sizes": [
{
"id": 1,
"sizeName": "XL",
"count": 10
}
],
"price": 100.0,
"discount": 0
},
{
"id": 2,
"category": null,
"model": "new shoes",
"mark": "NIKE",
"sizes": [],
"price": 199.0,
"discount": 0
},
],
"pageable": {
"sort": {
"sorted": false,
"unsorted": true,
"empty": true
},
"offset": 0,
"pageNumber": 0,
"pageSize": 20,
"unpaged": false,
"paged": true
},
"last": true,
"totalPages": 1,
"totalElements": 4,
"size": 20,
"number": 0,
"sort": {
"sorted": false,
"unsorted": true,
"empty": true
},
"first": true,
"numberOfElements": 4,
"empty": false
}
This content is causing issues in my Angular code as it cannot handle it properly. Here is my service:
getAll(){
return this.http.get("http://localhost:8080/items?page=0");
}
And here is my component.ts:
pantService.getAll().subscribe(result => {
console.log(result)
console.log(result.content)
});
I need to paste this result into my itemsList array.