Paldom / angular2-rest

Angular2 HTTP client to consume RESTful services. Built with TypeScript.
MIT License
248 stars 72 forks source link

Only json.stringify when the content type is application/json #16

Open Nehon opened 8 years ago

Nehon commented 8 years ago

Hey really nice library you have here.

I stumbled on an issue though and figured out that the body (added with @Body) is always passed to JSON.stringify(). It's a problem when you want to send something that is not json. https://github.com/Paldom/angular2-rest/blob/master/angular2-rest.ts#L192

It's very convenient of course when you want to send JSON, which is the case most of the time. But IMO this process should only be done when the content type is set to application/json.

It would be awesome to support any other content type encoding...but quite cumbersome, so I suggest to let the user format the body the way he wants when the content type is not application/json.