Skip to content
Darkmown 2.7

What the API actually said

A real API explains why it refused. <name>_error used to read Error: HTTP 422 no matter what came back. It is now the body's own error or message string, and the whole parsed body lands in <name>_error_body, so a page can render per-field errors without a line of its own JavaScript.

A refusal, rendered

/api/echo only accepts POST, so a plain :fetch gets a 405 whose JSON body carries an error string.

Field-level errors

/api/upload answers a fileless POST with a 422 whose body carries both a sentence and a per-field map:

{ "error": "Pick a file first.", "fields": { "photo": "No file was attached." } }

A page renders each half where it belongs:

:if signup_error
{ signup_error }
:endif

{ signup_error_body.fields.email }

The upload demo has this wired up end to end.

The rules

Read the docs on fetching data