jonsamwell / angular-http-batcher

Enables HTTP batch request with AngularJS
MIT License
96 stars 28 forks source link

Incorrect call to angular.toJson on request bodies #5

Closed riaann closed 9 years ago

riaann commented 9 years ago

When batching requests that have request bodies, such as "POST" requests, the standard angular request transforms convert objects into json strings. When angular-http-batcher calls angular.toJson again, we end up with a single json string, instead of a json encoding of the object in the batched request.

So, instead of {"name":"John"} as the body of the request in the batch, you get "{\"name\":\"John\"}" - which causes the parameter binding in Web API to break.

The solution we've found is to remove the angular.toJson call in your HttpBatcher. I'm happy to do a pull request if you prefer.

jonsamwell commented 9 years ago

Hi - thanks for find this. Yeah do a PR with passing unit tests! Thanks

jonsamwell commented 9 years ago

Hi, this seems to work OK. A few tests fail but only for formatting reason which I can fix. I'll aim to fix this and push a release up to bower this evening :-)

jonsamwell commented 9 years ago

I have remove this un-necessary call to angular.toJson and fixed the failing tests. It is pushed up to the main repo and bower as v1.5.0.

@RiaanN - Can you give it a test and see if it works for you?

Thanks,

Jon