FetchEvent()
The FetchEvent()
constructor creates a new FetchEvent
object.
Syntax
var fetchEvent = new FetchEvent(type, init);
Parameters
type
-
A
DOMString
object specifying which event the object represents. This is alwaysfetch
for Fetch events. -
init
Optional -
An object conforming to the
FetchEventInit
dictionary, containing options to apply to the event object. Options are as follows:-
clientId
Read only -
The
Client
that the current service worker is controlling. -
isReload
Read only -
A boolean value that signifies whether the page was reloaded or not when the event was dispatched.
true
if yes, andfalse
if not. Typically, pressing the refresh button in a browser is a reload, while clicking a link and pressing the back button is not. If not present, it defaults tofalse
. -
preloadResponse
Read only -
A
Promise
which returns a previously-loaded response to the client. -
replacesClientId
Read only -
A
DOMString
which identifies the client which is being replaced byresultingClientId
. -
resultingClientId
Read only -
A
DOMString
containing the newclientId
if the client changes as a result of the page load. -
request
Read only -
The
Request
object that would have triggered the event handler.
-
Specifications
Specification |
---|
Service Workers 1 # dom-fetchevent-fetchevent |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
FetchEvent |
40 |
17 |
44
Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API.
|
No |
27 |
11.1 |
40 |
40 |
44 |
27 |
11.3 |
4.0 |
See also
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/FetchEvent