FetchEvent: clientId property
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("Service Workers API")}}{{AvailableInWorkers("service")}}
The **clientId** read-only property of the {{domxref("FetchEvent")}} interface returns the id of the {{domxref("Client")}} that the current service worker is controlling.
The {{domxref("Clients.get()")}} method could then be passed this ID to retrieve the associated client.
Value
A string that represents the client ID.
Examples
js
self.addEventListener("fetch", (event) => {
console.log(event.clientId);
});Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- Using Service Workers
- Service workers basic code example
- Using web workers