Implement the Fetch API, returning Promises and backed by the existing net crate (HTTP/1.1 + TLS).
Scope#
fetch() Global Function#
fetch(url)— initiate HTTP GET, return Promisefetch(url, options)— support options:method— HTTP method (GET, POST, PUT, DELETE, etc.)headers— object or Headers instancebody— string body for POST/PUT
- Returns a Promise that resolves to a Response object
- Promise rejects on network errors (DNS failure, connection refused, TLS errors)
Response Object#
response.ok— boolean, true if status 200-299response.status— HTTP status code (number)response.statusText— status text stringresponse.headers— Headers objectresponse.url— final URL after redirectsresponse.text()— return Promise of response bodyresponse.json()— return Promise