CRUD POST action with no url params is empty
divan opened this issue · 1 comments
divan commented
I have a simple endpoint:
users: { url: `/api/users`, crud: true, transformer: transformers.array },
and when I try to do POST request:
dispatch(rest.actions.users.post({}, {name: "New user"})
the resulting POST request is empty (i.e. has no data and Content-Lenght is 0).
If I specify an url params like this:
dispatch(rest.actions.users.post({id: 42}, {name: "New user"})
it works as expected.
But in this case (it's CREATE in terms of CRUD), I don't have any id to pass (obviously).
Am I doing something wrong or is it a bug?
divan commented
Sorry, it was me doing something wrong.
Right way to do it (not really obvious :/):
dispatch(rest.actions.users.post({}, { body: JSON.stringify{name: "New user"} } )