Skip to main content

Overview

The fetch built-in member makes HTTP requests with built-in retry, timeout, and response parsing.
- member: api-call
  type: Function
  config:
    builtin: fetch
    url: https://api.example.com/data
    method: GET
    headers:
      Authorization: Bearer ${env.API_KEY}

Configuration

url
string
required
Request URL
method
string
default:"GET"
HTTP method
headers
object
Request headers
body
any
Request body
timeout
number
default:"30000"
Timeout in milliseconds

Examples

GET Request

- member: fetch-data
  type: Function
  config:
    builtin: fetch
    url: ${input.apiUrl}
    method: GET

POST Request

- member: post-data
  type: Function
  config:
    builtin: fetch
    url: ${env.API_URL}
    method: POST
    headers:
      Content-Type: application/json
    body:
      data: ${input.data}

With Retry

- member: resilient-fetch
  type: Function
  config:
    builtin: fetch
    url: ${input.url}
  retry:
    maxAttempts: 3
    backoff: exponential

Output

interface FetchOutput {
  status: number;
  data: any;
  headers: Record<string, string>;
  duration: number;
}