useFetcher(MyResource.updateShape()) crashing because PUT call returns empty response body
React version 16
Concurrent mode No
Describe the bug
useFetcher(MyResource.updateShape()); crashes if the API returns an empty response body.
To Reproduce
Use useFetcher(MyResource.updateShape()); with an API returning an empty response body.
Expected behavior Shouldn't crash.
Additional context I temporally fixed this issue by making this change... (NetworkManager.ts:162)
case 'rest-hooks/receive':
++ if (!action.payload) action.payload = {};
// only receive after new state is computed
return next(action).then(() => {
if (action.meta.url in this.fetched) {
this.handleReceive(action);
}
});
What error message is thrown?
Unexpected input given to normalize. Expected type to be "object", found "string".
Have a solution for this up soon. You'll need to ensure your schema is reflecting the expected response. Add this to your Resource:
static updateShape() {
return {
...super.updateShape(),
schema: '',
};
}
Released 4.0.1