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

useFetcher(MyResource.updateShape()) crashing because PUT call returns empty response body

Open ChristopherMillon opened this issue 6 years ago • 4 comments

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);
              }
            });

ChristopherMillon avatar Dec 30 '19 20:12 ChristopherMillon

What error message is thrown?

ntucker avatar Dec 30 '19 20:12 ntucker

Unexpected input given to normalize. Expected type to be "object", found "string".

ChristopherMillon avatar Dec 30 '19 21:12 ChristopherMillon

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: '',
  };
}

ntucker avatar Dec 31 '19 03:12 ntucker

Released 4.0.1

ntucker avatar Dec 31 '19 03:12 ntucker