Clients: get() method

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("Service Workers API")}}{{AvailableInWorkers("service")}}

The **get()** method of the {{domxref("Clients")}} interface gets a service worker client matching a given id and returns it in a {{jsxref("Promise")}}.

Syntax

js-nolint
get(id)

Parameters

  • id
  • : A string representing the id of the client you want to get.

Return value

A {{jsxref("Promise")}} that resolves to a {{domxref("Client")}} object or undefined.

Examples

js
self.clients.get(id).then((client) => {
  self.clients.openWindow(client.url);
});

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}