BackgroundFetchManager: get() method
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("Background Fetch API")}}{{SeeCompatTable}}{{AvailableInWorkers}}
The **get()** method of the {{domxref("BackgroundFetchManager")}} interface returns a {{jsxref("Promise")}} that resolves with the {{domxref("BackgroundFetchRegistration")}} associated with the provided id or {{jsxref("undefined")}} if the id is not found.
Syntax
get(id)Parameters
id- : The ID of a {{domxref("BackgroundFetchRegistration")}} defined by calling {{domxref("BackgroundFetchManager.fetch","fetch()")}}.
Return value
A {{jsxref("Promise")}} that resolves with a {{domxref("BackgroundFetchRegistration")}} or {{jsxref("undefined")}}.
Examples
The following example shows how to use get() to retrieve a {{domxref("BackgroundFetchRegistration")}}. With an active service worker, use the {{domxref('ServiceWorkerRegistration.backgroundFetch')}} to access the BackgroundFetchManager object and call its get() method.
navigator.serviceWorker.ready.then(async (swReg) => {
const bgFetch = await swReg.backgroundFetch.get("my-fetch");
});
// my code blockSpecifications
{{Specifications}}
Browser compatibility
{{Compat}}