Skip to main content
The raw Response returned by fetch() can be accessed through the .asResponse() method on the APIPromise type that all methods return. You can also use the .withResponse() method to get the raw Response along with the parsed data.

Using .asResponse()

The .asResponse() method returns the raw Response object without parsing the body:
Use .asResponse() when you need to access headers, status codes, or other response metadata.

Using .withResponse()

The .withResponse() method returns both the parsed data and the raw Response object:
.withResponse() is useful when you need both the parsed data and response metadata.

Common use cases

Accessing response headers

Response headers contain useful metadata like rate limits and request IDs:

Checking status codes

Access the HTTP status code and status text:

Inspecting response timing

You can measure request duration by tracking timestamps:

Response headers reference

Common Cloudflare API response headers:
string
Unique request identifier for debugging
number
Number of requests remaining in the current rate limit window
timestamp
Unix timestamp when the rate limit window resets
number
Total number of requests allowed in the rate limit window

Working with pagination

Access pagination metadata from response headers:
Pagination header names may vary by endpoint. Check the specific API documentation for details.