• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Unwrapping a promise to get at data inside

Resolved: Unwrapping a promise to get at data inside

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

My Spring Boot back-end sends responses to front-end requests like this:
How do I unwrap this response so that I can store the value of “products” (the products array) in the data variable below and display it in my table (I’m using Material btw)?
You can see that the above won’t work because I am sending the whole response (including the timestamp and status fields) to the data variable which only expects an array like this: [{"product1":"Rake"},{"product2":"Hammer"},...].
Here is my service class:

Answer:

Your service doesn’t return ProductTableItem but the server response. Create two models:
and
Now in your service:
and in your component:

If you have better answer, please add a comment about this, thank you!

angular promise typescript
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How to resolve LNK2001 in c++ projects

26/03/2023

Resolved: How to correctly initialize vector of number in Typescript

26/03/2023

Resolved: mysql calculating to get profit or loss from 2 tables ( Purchases and Sales) in FIFO mode

26/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.