I tried this using HttpClient and a data service for my angular project, and it returns the mapped object, but the value of that http function is an observable object. I've no clue what I'm doing wrong to not get the right value.
The Angular HttpClient is designed to work with Observables (data streams), and this approach is Promise-based. You have two options:
Work with Observables, where you have to subscribe to the Observable object in order to access its data. You can find more information here
You can you use the toPromise() utility, which will transform the Observable you are receiving to a Promise, which you can then handle in the traditional way. More info about toPromise here
I hope this helps you out. Let me know :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I tried this using HttpClient and a data service for my angular project, and it returns the mapped object, but the value of that http function is an observable object. I've no clue what I'm doing wrong to not get the right value.
The Angular HttpClient is designed to work with Observables (data streams), and this approach is Promise-based. You have two options:
Work with Observables, where you have to subscribe to the Observable object in order to access its data. You can find more information here
You can you use the toPromise() utility, which will transform the Observable you are receiving to a Promise, which you can then handle in the traditional way. More info about toPromise here
I hope this helps you out. Let me know :)