Introduction
Astro forms ship with some utility functions to handle forms.
Some functionality works by sending the script to the client and running it there.
You can access them via Astro.locals.forms
.
Controllers
Example
Throw Response
If you want to throw a response from the server.
Meaning you in a nested function and you encore an error and you want to override an response and abort the current page execution.
You can use the ThrowOverrideResponse
class.
Example
Edge case:
- If no
Response
is provided, will be use the response stored in locals.forms.overrideResponse
.
- If no
Response
is stored in locals.forms.overrideResponse
, will be return the message with error code 500.
Edge case example
Or you can just pass an error message: