Closed aloysb closed 3 years ago
And the error from the devTools.
error{
"name": "SyntaxError",
"message": "Unexpected end of JSON input",
"stack": "SyntaxError: Unexpected end of JSON input"
}
I'm unusure why. Other mutations seem to be working fine.
I think the Mutation is rejected because the API doesn't return a body (204) (c.f. expected response from RTK - Q). So it might be normal behaviour.
I tried to force the validation of the mutation by adding:
validateStatus: (response) => response.status === 204
Did not work though. So the issue might be with validateStatus rather than unexpected rejection.
As a work around, I am just forcing the 'refetch' on this particular Mutation, just curious to understand why it doesn't work.
That sounds like https://github.com/rtk-incubator/rtk-query/issues/89
You can use the current dev build from https://ci.codesandbox.io/status/rtk-incubator/rtk-query/pr/1 that already includes a patch.
That's right, same issue.
I'll close this. However, why the validateStatus function wouldn't 'force' its way through?
I'll rename the issue so people can find it.
no matter if you validate or not, if the parsing of the response literally crashes, it wasn't successful as you're not able to access the result.
The following mutation gets rejected (I've rewritten it several times to ensure it works, this one is a coming from the docs):
Action:
But the API is hit and updated, however the mutation returns 'rejected' which in turns doesn't trigger the invalidation.