Skip to main content
A hoisted 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

Promise<Response>
A Promise that resolves to a Response object.

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.fetch inside workflow functions. Always import and use fetch from the workflow package.
  • 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 fetch function from workflow can only be called inside workflow functions (with "use workflow")
  • Standard Fetch API: Follows the Fetch API specification