this post was submitted on 22 Mar 2025
753 points (99.0% liked)

Programmer Humor

21893 readers
2109 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] paequ2@lemmy.today 6 points 5 days ago (1 children)

I've seen the status code in a JSON response before: https://cloud.google.com/storage/docs/json_api/v1/status-codes#401-unauthorized

One reason I can think of for including it is that it may make it easier for the consumer to check the status code if it's in the JSON. Depending on how many layers of abstraction you have, your app may not have access to the raw HTTP response.

Although, yeah you lose the single source of truth though.

[–] zalgotext@sh.itjust.works 7 points 5 days ago (1 children)

Depending on how many layers of abstraction you have, your app may not have access to the raw HTTP response.

That sounds like either over-abstraction or bad abstraction then

[–] Takumidesh@lemmy.world 3 points 4 days ago* (last edited 4 days ago)

Yea, I don't really see a scenario where you are both, making http requests (and therefore care about http responses), and also not able to see the response.

If you are using some wrapper client for an API, you wouldn't be dealing with the response anyway so it being in json isn't particularly helpful