question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`responseType` – ignore 204 No Content?

See original GitHub issue

My 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:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jamespleasecommented, Jul 24, 2016

Sure!

Awesome. I’ll whip up a PR sometime in the next few days.

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.

Noted. I’ll keep it succinct. ✌️

0reactions
naugturcommented, Jul 24, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found