Just audited a codebase with a REST API that returns this: { table1: []...
Just audited a codebase with a REST API that returns this:
{
table1: []
table2: []
main: []
}
Don’t couple your API to UI elements.
Clarification: Backend for frontend is a great pattern.
But the API response should typically avoid specifying the exact HTML element a given piece of data is for.
Avoid this:
{ userTable: [] }
Prefer this:
{ users: [] }
The latter is more flexible.
I just realized:
If you define REST as “Use HTTP verbs and return JSON”, you probably agree with me.
If you define REST as “Hypermedia as the Engine of Application State” (HATEOES) you probably disagree with me.