Open marekpw opened 8 years ago
You can implement the method responseInterceptor or you can use @Produces(MediaType.JSON)
Thank you, I wasn't aware of the responseInterceptor method. It will be possible, although a bit messy, due to multiple data outputs based on if I fetch a single resource or a collection.
Could you please explain what does the @Produces decorator do? It's not documented anywhere.
I found it in the code. At the moment it accepts only MediaType.JSON and, if it is specified, the observable passes to the next subscriber a json object instead of a Response object.
Ciao Angelo
I'm new to observables and this service seems to use them heavily. I'd like to transform the response so that it creates a collection (on GET resource/) of entities implementing an interface describing them, or a single entity on GET resource/id.
The response from my API is something like this:
The method to receive this object is pretty basic:
In my component which injects this Rest client, I use:
Now, I have two options:
1) the ugly solution: Pass the res.json() results to another service in the observer callback which transforms the data array of the response to an array of entities. The downside is that I'd have to copy-paste this everywhere I want to get the data from the client.
2) the nice solution: Somehow transform the response into entities in the client itself, then just pass the array of entities to the observer callback.
Any help is welcome.