Overview
TheCallApiRequestOptions interface defines the core HTTP request parameters like method, headers, body, and other standard fetch options.
Type Definition
Properties
body
Body of the request, can be an object or any other supported body type.Supported body types:
- Plain objects (automatically serialized to JSON)
- FormData
- URLSearchParams
- Blob
- ArrayBuffer
- ReadableStream
- String
headers
Headers to be used in the request.Can be provided as:
- Plain object
- Headers instance
- Array of tuples
method
HTTP method for the request.Supported methods:
- GET
- POST
- PUT
- PATCH
- DELETE
- HEAD
- OPTIONS
Standard Fetch Options
In addition to the core properties,CallApiRequestOptions includes standard fetch options:
cache
Cache mode for the request.Options:
default, no-store, reload, no-cache, force-cache, only-if-cachedcredentials
Controls whether to send credentials (cookies) with the request.Options:
omit, same-origin, includeintegrity
Subresource integrity value for the request.
keepalive
Indicates whether the request should outlive the page.
mode
Request mode.Options:
cors, no-cors, same-origin, navigateredirect
How to handle redirects.Options:
follow, error, manualreferrer
Referrer of the request.
referrerPolicy
Referrer policy for the request.Options:
no-referrer, no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-urlsignal
AbortSignal to abort the request.
window
Can only be null. Used for worker contexts.
duplex
Duplex mode for streaming request bodies.
Examples
Simple GET Request
POST with JSON Body
File Upload with FormData
PUT Request with Custom Headers
DELETE Request
Request with AbortSignal
CORS Request
Streaming Request Body
Best Practices
-
Content-Type Headers: Set appropriate
Content-Typeheader for your request body:application/jsonfor JSON objectsmultipart/form-datafor FormData (automatically set)application/x-www-form-urlencodedfor URLSearchParams
-
Method Selection: Use appropriate HTTP methods:
- GET for retrieving data
- POST for creating resources
- PUT for full updates
- PATCH for partial updates
- DELETE for removing resources
-
Request Cancellation: Use
AbortSignalfor requests that may need to be cancelled: -
Credentials: Set
credentials: 'include'when making authenticated cross-origin requests that require cookies.
See Also
- BaseCallApiConfig - Base configuration interface
- CallApiExtraOptions - Additional configuration options
- Hooks - Request/response lifecycle hooks