devour-client icon indicating copy to clipboard operation
devour-client copied to clipboard

Unable to use `fields` with a POST/PUT request

Open simonc opened this issue 6 years ago • 1 comments

Hello there,

We've been experiencing an issue with Devour where passing fields: { comments: 'title' } will not get serialized for create or update calls.

For GET requests it will pass fields[comments]=title but for other types of requests it will send fields={"comments": "title"}.

I could track this issue down to those lines:

https://github.com/twg/devour/blob/e27377c3b5734ae026ff770477fee608c2f4d936/src/middleware/json-api/rails-params-serializer.js#L6-L13

I suppose that this kind of if has a reason for being present but I didn't find one.

  1. Is there a way to change this behavior without having to fork/patch Devour?
  2. Would you be interested in a PR to remove the if ?

Thanks ❤️

simonc avatar May 28 '19 15:05 simonc

@simonc I'd be interested in getting a PR out removing the if. I'm not sure what the JSON:API spec is related to this, maybe it only allows for field parameters with GET requests?

Auspicus avatar Jul 26 '19 16:07 Auspicus