`responseType` – ignore 204 No Content?
See original GitHub issueMy API returns JSON objects always, except in certain situations when a 204 No Content
is returned. This is used, for instance, for successful deletes. (for further reading, check out the JSON API spec)
Setting responseType: 'json'
blows up when this happens, because an empty response isn’t json. The immediate reaction might be, well, don’t specify the response type. I’d like to, however, because errors and all other unsuccessful deletes are returned in a JSON format.
Do folks think that it makes sense for responseType
to skip trying to parse the (nonexistent) body if 204
is returned?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
204 No Content - HTTP - MDN Web Docs - Mozilla
The HTTP 204 No Content success status response code indicates that a request has succeeded, but that the client doesn't need to navigate ......
Read more >HTTP Get with 204 No Content: Is that normal - Stack Overflow
I use GET/204 with a RESTful collection that is a positional array of known fixed length but with holes. GET /items 200: ["a",...
Read more >Null API Responses and HTTP 204 Results in ASP.NET Core
ASP.NET Core 3.x has a behavior that results in API results that return null from the controller action returning a HTTP 204 -...
Read more >HTTP/1.1: Status Code Definitions
Unexpected 1xx status responses MAY be ignored by a user agent. ... The 204 response MUST NOT include a message-body, and thus is...
Read more >HTTP Status 204 (No Content) - REST
HTTP Status 204 (No Content) indicates that the server has successfully fulfilled the request and that there is no content to send in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Awesome. I’ll whip up a PR sometime in the next few days.
Noted. I’ll keep it succinct. ✌️
Sure!
It’s demonstrated for GET because it wasn’t obvious even for https://github.com/request/request users I’m looking forward to a cleaner explanation. All I can ask is that you make sure it’s short and not stealing attention from everything else in the README.md - other than that, there’s nothing stopping what you write from getting merged.