BackgroundFetchRecord
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Note: This feature is available in Web Workers.
Giao diện BackgroundFetchRecord của Background Fetch API biểu diễn một yêu cầu và phản hồi riêng lẻ.
Một BackgroundFetchRecord được tạo bởi phương thức BackgroundFetchRegistration.matchAll(), vì vậy giao diện này không có hàm khởi tạo.
Sẽ có một BackgroundFetchRecord cho mỗi tài nguyên được yêu cầu bởi fetch().
Thuộc tính thể hiện
requestRead only Experimental-
Trả về một
Request. responseReadyRead only Experimental-
Trả về một promise phân giải với một
Response.
Ví dụ
Trong ví dụ này, một BackgroundFetchRecord riêng lẻ được trả về bằng BackgroundFetchRegistration.matchAll(). BackgroundFetchRecord.request và BackgroundFetchRecord.responseReady được trả về và ghi ra console.
bgFetch.match("/ep-5.mp3").then(async (record) => {
if (!record) {
console.log("No record found");
return;
}
console.log(`Here's the request`, record.request);
const response = await record.responseReady;
console.log(`And here's the response`, response);
});
Thông số kỹ thuật
| Specification |
|---|
| Background Fetch> # background-fetch-record-interface> |