Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check response.ok? #12

Open
vincerubinetti opened this issue Nov 20, 2019 · 0 comments
Open

check response.ok? #12

vincerubinetti opened this issue Nov 20, 2019 · 0 comments

Comments

@vincerubinetti
Copy link

vincerubinetti commented Nov 20, 2019

Thank you for the library. It is very handy.

Not sure if everyone would want to have this, but looking at the code, it's just a try/catch to determine if the request failed or not. Perhaps a falsey response.ok should also count as a failure?

If you think it wouldn't be good to include by default, perhaps in the readme it'd be good to mention that a user can check for it in their api call like this:

const myFetch = createActionThunk('MY_FETCH', async () => {
  const response = await fetch(someUrl);
  if (!response.ok)
    throw new Error(response);
  const json = await response.json();
  return json;
});
@vincerubinetti vincerubinetti changed the title check status.ok? check response.ok? Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant