Web APIs
Request constructor
Creates a request description without sending it. Method, headers, body and signal are supplied through options.
Formal Syntax & Structure
javascript syntaxjavascript
new Request(input, init?)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| input | string | URL | Request | Target or request to copy. |
| init | RequestInit | Optional configuration. |
Return Value
Request
Constructed request.
Working Example
Example Snippetjavascript
(async () => {const r=new Request("https://example.test/items",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({qty:3})});console.log(r.method,r.headers.get("content-type"),await r.text());})()