Documentation Index
Fetch the complete documentation index at: https://prefab.prefect.io/docs/llms.txt
Use this file to discover all available pages before exploring further.
Fetch makes HTTP requests from the browser using the native fetch() API. Use it to call REST endpoints, load external data, or submit forms — anything that speaks HTTP without needing an MCP server in the middle.
The response is parsed automatically — JSON becomes an object, everything else becomes a string. The on_success callback fires after a successful request, and the parsed response is available as $result (Python: RESULT). Use SetState("users", RESULT) inside on_success to write the response into client-side state, making it immediately available via {{ users }} interpolation.
Classmethods
Each HTTP method has a dedicated classmethod with a tailored signature.GET accepts query params, while POST/PUT/PATCH accept a body.
GET with query params
POST with JSON body
DELETE
Fetch directly for full control:
Full form
Error Handling
Non-2xx responses triggeron_error with the status line as $error. This follows the same callback pattern as every other Prefab action.
Error handling
Request Bodies
Dict bodies are automatically JSON-serialized with aContent-Type: application/json header. String bodies are sent as-is — useful for form-encoded data or raw text. The auto-set Content-Type won’t override a header you set explicitly.
Combined with Client Actions
Like any action,Fetch composes in a list. A common pattern: show a loading state, make the request, then clear it.
Combined actions
SetState("loading", False) never runs (the chain short-circuits). Use on_error on the Fetch to handle that case.
API Reference
Fetch Parameters
URL to fetch. Supports
{{ key }} interpolation. Can be passed as a positional argument.HTTP method:
GET, POST, PUT, PATCH, or DELETE.Request headers. Values support
{{ key }} interpolation.Request body. Dicts are JSON-serialized automatically. Ignored for GET requests.
Protocol Reference
Fetch