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

Should HTTP 400+ be considered errors? #7

Closed
DavidBruant opened this issue Jan 29, 2018 · 3 comments
Closed

Should HTTP 400+ be considered errors? #7

DavidBruant opened this issue Jan 29, 2018 · 3 comments

Comments

@DavidBruant
Copy link
Contributor

The current d3.json function would not consider a 404 or a 500 an error, but doesn't forward the status code to verify it either. This might lead to hard-to-debug code.

Happy to send a PR if there is consensus

@mbostock
Copy link
Member

Yes, this is a bug; we should check the response status code. If people want to parse the responses for non-success status codes, it should be reasonable for them to just use the Fetch API directly (since this module is already a very thin layer on top of fetch).

The logic in d3-request was something like:

if (!status && hasResponse(xhr)
    || status >= 200 && status < 300
    || status === 304) {
  
}

I think what we want in d3-fetch is to check response.ok.

@DavidBruant
Copy link
Contributor Author

<3

@mbostock
Copy link
Member

Fixed in 1.0.1. Thanks for the feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants