blob: 29bcc963fbb3f354393570a932380f44afd1e384 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
---
title: Clients.get()
slug: Web/API/Clients/get
tags:
- API
- Clients
- Méthode
- Reference
- Service Workers
- get
translation_of: Web/API/Clients/get
---
{{SeeCompatTable}}{{APIRef("Service Workers API")}}La méthode **`get()`** de l'interface {{domxref("Clients")}} récupère un service worker client correspondant à un id donné et le retourne dans une {{jsxref("Promise")}}.
## Syntaxe
```js
self.clients.get(id).then(function(client) {
// Faire quelque chose avec le client
});
```
### Paramètres
- `id`
- : Une {{domxref("DOMString")}} représentant l'id du client que vous souhaitez récuperer.
### Valeur de retour
Une [`Promise`](/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) qui se résoud avec un objet {{domxref("Client")}}.
## Exemples
```js
self.clients.get(options).then(function(client) {
self.clients.openWindow(client.url);
});
```
## Spécifications
| Spécification | Statut | Commentaires |
| ------------------------------------------------------------------------------------ | ------------------------------------ | ------------------- |
| {{SpecName('Service Workers', '#clients-get-method', 'get()')}} | {{Spec2('Service Workers')}} | Définition initiale |
## Compatibilité des navigateurs
{{Compat("api.Clients.get")}}
|