The exact same API. Now with rounded corners, bigger fonts, and fewer scary words.
This is the whole API. Two blocks. You send JSON, you get JSON back. Nothing re-renders. There is no useEffect. Nobody gets hydrated.
If you can write fetch(), you can use this. If you can't write fetch() yet — that's fine, a renderer is on the way that draws this whole thing as little colored blocks you drag around. Like Scratch. Like when you were eight and actually shipped something.
POST /api/v2/client/getinfoPOST /api/v2/client/orderThat's the entire framework. Sorry — API. Force of habit.
Put your token in a header called X-API-Token. A header. The part that isn't the body. You've met them — they live in the Network tab, between npm installs.
Looking at the menu is public: no token needed. You only need the token to actually order, because ordering does something real in the real world.
Everything looks like this:
{ "v": 2, "status": 0, "data": { ...the good stuff... } }status is 0 when it worked and 1 when it didn't. When it's 1 we put what went wrong in error.msg, in actual human sentences. No stack-trace archaeology. You're welcome.
There is one. You won't reach it.
Ask for the parts of the venue you want — all at once, in one request. One. Not one request per component. Not one per useQuery. One.
List what you want inside query. Want the menu and the categories? Send { "query": { "items": {}, "categories": {} } }. Each thing you ask for comes back in data under the same name.
Things you can ask for: info (the venue), categories, items (the menu), tables, zones, events. Use {} as the value — they're useful with no options at all.
No loading spinner required. We know you'll add three anyway.
{
"v": 2,
"status": 0,
"data": {
"info": {
"name": "Demo Bistro"
},
"categories": [
{
"id": 1,
"name": "Burgers"
}
],
"items": [
{
"id": 220,
"name": "Classic Burger",
"price": 32
}
]
},
"meta": []
}
Send a table and a list of items. Each item is { "item": <product id>, "count": <how many> }. Add "notes" if the customer is particular.
The kitchen finds out immediately. You don't wire up a single websocket — we already did that part, in C++, while you were picking a state library.
Bonus, because we both know your users double-tap buttons: add any number as idempotency_key and retry as much as you like. Same number = same order, no duplicates. It's that easy, and no, you don't need a reducer for it.
{
"v": 2,
"status": 0,
"data": {
"placed": true,
"id_sep": 1
},
"meta": []
}
{
"v": 2,
"status": 1,
"error": {
"code": "INVALID_ITEM",
"msg": "Format invalid pentru produs sau cantitate."
}
}
🍔 Asta e tot framework-ul. Pardon — API-ul. Forța obișnuinței.