pub fn fetch(
request: Request,
on_done: impl 'static + Send + FnOnce(Result<Response>)
)
Expand description
Performs an HTTP request and calls the given callback when done.
Ok
is returned if we get a response, even if it’s a 404.
Err
can happen for a number of reasons:
- No internet connection
- DNS resolution failed
- Firewall or proxy blocked the request
- Server is not reachable
- The URL is invalid
- Server’s SSL cert is invalid
- CORS errors
- The initial GET which returned HTML contained CSP headers to block access to the resource
- A browser extension blocked the request (e.g. ad blocker)
- …