global.RequestInit
Shapes a fetch request: its method, headers and body, and a signal that cancels it.
Usage
Measure an operation without relying on wall-clock changes.
This type is used by global.fetch
// Measure an operation without relying on wall-clock changes.
const start = performance.now();
const response = await fetch('https://example.com/api/health');
console.log(response.status, performance.now() - start);Type declaration
interface RequestInit {
method?: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS';
headers?: HeadersInit;
/**
* A string goes as UTF-8, `text/plain;charset=UTF-8` unless a content type
* is set; URLSearchParams as a form.
*/
body?: BodyInit | null;
signal?: AbortSignal | null;
}Members 4
| Name | Type | Required | Description |
|---|---|---|---|
method | "POST" | "PUT" | "PATCH" | "GET" | "HEAD" | "DELETE" | "OPTIONS" | No | — |
headers | HeadersInit | No | — |
body | BodyInit | No | A string goes as UTF-8, text/plain;charset=UTF-8 unless a content type
is set; URLSearchParams as a form. |
signal | AbortSignal | No | — |
Generated from the public TypeScript declarations: signatures, props and defaults come from the checked source, descriptions from its JSDoc. No defaults are invented.