Web APIs
fetch()
Initiates a fetch and returns a promise for a Response. Rejects on network or policy failure, not merely an HTTP error status.
Formal Syntax & Structure
javascript syntaxjavascript
fetch(input, init?)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| input | string | URL | Request | Request target or object. |
| init | RequestInit | Optional request settings. |
Return Value
Promise<Response>
Promise for the response.
Working Example
Example Snippetjavascript
(async () => {const r=await fetch("data:text/plain,hello");console.log(r.status,await r.text());})()