this post was submitted on 22 Mar 2025
746 points (98.8% liked)

Programmer Humor

21881 readers
991 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
[–] RizzoTheSmall@lemm.ee 76 points 4 days ago (15 children)

I know an architect who designs APIs this way. Also includes a status code in the response object because why have one status code when you can have two, potentially contradictory, status codes?

[–] paequ2@lemmy.today 6 points 4 days ago (2 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 7 points 4 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

load more comments (12 replies)