troyanskiy / ngx-resource

Resource (REST) Client for Angular 2
http://troyanskiy.github.io/ngx-resource/
200 stars 46 forks source link

Body serialization #131

Closed kptLucek closed 7 years ago

kptLucek commented 7 years ago

Hi

Is there any chance to change way, that body is being serialized?

Right now it's made by JSON.stringify, but... it resuts in many problems with backend API im using for that project.

The perfect way for me, would be to choose between stringify and for example URLSearchParams (aka, NG1 $httpParamSerializer) described in here.

If it's not possible to implement any soon, then any workaround more than welcome.

troyanskiy commented 7 years ago

Hello! Thanks for the issue. I've just implemented that for you. Published 3.3.0

  1. You can overwrite Resource method $bodySerializer(body: any): string to implement customs serializer.
  2. Or you can define if with ResourceAction decorator bodySerializer(body: any): string to implement custom serializer per resource method.
kptLucek commented 7 years ago

Works like a charm!

troyanskiy commented 7 years ago

I'm glad to hear that.