FetchEvent Class
The fetch event of a service worker (https://w3c.github.io/ServiceWorker/#fetchevent): a request of a client of the service worker, which the service worker can answer with FetchEvent.RespondWith. The request and the response are Request and Response objects of the script engine (the Fetch API is implemented in JavaScript).
public sealed class FetchEvent : ExtendableEvent- Inheritance
ExtendableEventFetchEvent
Constructors
| Name | Description |
|---|---|
| FetchEvent(string, FetchEventInit) | Creates a fetch event. |
FetchEvent(string, FetchEventInit)
ExtendableEvents.csCreates a fetch event.
public FetchEvent(string type, FetchEventInit eventInitDict)Properties
| Name | Description |
|---|---|
| ClientId | Gets the id of the client of the request, or an empty string. |
| Handled | Gets the promise fulfilled once the event was handled. |
| PreloadResponse | Gets the promise of the response of the navigation preload (a Response object of the script engine, or undefined). |
| ReplacesClientId | Gets the id of the client replaced by a navigation, or an empty string. |
| Request | Gets the request: a Request object of the script engine. |
| ResultingClientId | Gets the id of the client created by a navigation, or an empty string. |
ClientId
ExtendableEvents.csGets the id of the client of the request, or an empty string.
public string ClientId { get; }Handled
ExtendableEvents.csGets the promise fulfilled once the event was handled.
public Task Handled { get; }PreloadResponse
ExtendableEvents.csGets the promise of the response of the navigation preload (a Response object of the script engine, or undefined).
Property value
See also
ReplacesClientId
ExtendableEvents.csGets the id of the client replaced by a navigation, or an empty string.
public string ReplacesClientId { get; }Request
ExtendableEvents.csGets the request: a Request object of the script engine.
public object Request { get; }ResultingClientId
ExtendableEvents.csGets the id of the client created by a navigation, or an empty string.
public string ResultingClientId { get; }Methods
| Name | Description |
|---|---|
| RespondWith(Task<object?>) | Answers the request with a response (https://w3c.github.io/ServiceWorker/#dom-fetchevent-respondwith): the promise must be fulfilled with a Response object, else the request is a network error. |
RespondWith(Task<object?>)
ExtendableEvents.csAnswers the request with a response (https://w3c.github.io/ServiceWorker/#dom-fetchevent-respondwith): the promise must be fulfilled with a Response object, else the request is a network error.
Parameters
Exceptions
DomException- An
InvalidStateErrorwhen the event is not being dispatched, or when the method was already called.