fetch() function that is executed as a step function, allowing you to make HTTP requests from within workflow functions.
This is the standard Fetch API wrapped as a step, providing durability and automatic retries for HTTP requests.
Signature
Parameters
RequestInfo | URL
required
The URL to fetch. Can be a string, URL object, or Request object.
RequestInit
Request options.
Returns
Usage
Basic GET Request
Fetch data from an API:POST Request with JSON
Send JSON data:Custom Headers
Include authentication headers:Handle Different Status Codes
Check response status:PUT Request
Update a resource:DELETE Request
Delete a resource:Form Data Upload
Submit form data:Query Parameters
Construct URLs with query parameters:Response Headers
Access response headers:Important Notes
- Must import from ‘workflow’: Do not use
globalThis.fetchinside workflow functions. Always import and usefetchfrom theworkflowpackage. - Executed as a step: Each fetch call is automatically wrapped as a step, providing durability and retry capabilities.
- Automatic retries: Failed requests are automatically retried according to your step retry configuration.
- Can only be used in workflows: The
fetchfunction fromworkflowcan only be called inside workflow functions (with"use workflow") - Standard Fetch API: Follows the Fetch API specification
Related
- RetryableError - Control fetch retry behavior
- FatalError - Mark fetch errors as non-retryable