ResponseExample
The example response of an endpoint, with its HTTP status as a light and a number.
import ResponseExample from '@sypnia/ui/astro/ResponseExample.astro'
On this page
Success and failure
4xx and 5xx turn the status to the failing tone.
Response200
{ "rows": [{ "id": 1042, "total": 38.5 }], "next": "c_9f2" } When the table does not exist404
{ "error": "table_not_found", "message": "There is no table «order». Did you mean «orders»?" } Code
---
import ResponseExample from '@sypnia/ui/astro/ResponseExample.astro';
import CodeBlock from '@sypnia/ui/astro/CodeBlock.astro';
---
<div class="sy-docs" style="min-height:0;background:none">
<ResponseExample status={200}><CodeBlock lang="json" code={`{ "rows": [{ "id": 1042, "total": 38.5 }], "next": "c_9f2" }`} /></ResponseExample>
<ResponseExample status={404} title="When the table does not exist"><CodeBlock lang="json" code={`{ "error": "table_not_found", "message": "There is no table «order». Did you mean «orders»?" }`} /></ResponseExample>
</div> When to use it
Use it when
- After RequestExample: one for success, one for each failure worth showing.
Do not use it when
- Listing every error: that is ErrorList.
For everyone
- The status is a number in words, not only a colour.