Skip to content

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
  1. Success and failure
  2. When to use it
  3. For everyone

Success and failure

4xx and 5xx turn the status to the failing tone.

Response200

JSON
{ "rows": [{ "id": 1042, "total": 38.5 }], "next": "c_9f2" }

When the table does not exist404

JSON
{ "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.
  1. Success and failure
  2. When to use it
  3. For everyone

    Search pages, sections and terms