0
self.addEventListener('sync', function(event) {
console.log('firing: sync');
if (event.tag == 'image-fetch') {
console.log('sync event fired');
event.waitUntil(fetchurl());
}
});
function fetchurl()
{
console.log('firing: doSomeStuff()');
/* fetch dynamic url */
fetch('https://localhost/Service-Workers-BackgroundSync/server.php')
.then(function(response) {
return response;
})
.then(function(text) {
console.log('Request successful', text);
})
.catch(function(error) {
console.log('Request failed', error);
});
}
service-worker.jsで動的URLを取得するにはどうすればよいですか?service-worker.jsの動的URLを更新する方法
私は 'sync'イベントを呼び出しています。 URLを動的に取得します。常に[送信]ボタンをクリックします。別のURLを取得しています。その後、同期イベントを使用してフェッチメソッドで動的URLを渡します。
私をご案内ください。