- From: Jxck <notifications@github.com>
- Date: Fri, 27 May 2016 01:55:19 -0700
- To: slightlyoff/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc:
- Message-ID: <slightlyoff/ServiceWorker/issues/904@github.com>
if I wanna send data to sever from page, but wanna also support offline using background sync. ```js // sending body 'a=b' to server self.addEventListener('fetch', (e) => { let req = e.request; // delegate to background sync self.addEventListener('sync', (e) => { fetch(req).then(/*....*/) }); e.respondTo(new Response('dummy')); }); ``` but in this case, `req` are at local memory, so this will remove when service worker process are down before sync event fired (in my understanding). so I need to save `req` to somewhere. but I don't have response, for saving this to caches. (saving request with dummy response to caches seems bad hack.) should I keep body in this request to indexed db ? it seems heavy for me to initialise / saving / getting IDB for saving only **"a=b"**. localStorage seems fit with this, it's handy to save body 'a=b' with some key and grab this when 'sync' event. but I know that I can't touch it in sw because of sync api. is there any other way to save body or request ? or localStorage will have Async API (returning promise) are welcome !! --- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/slightlyoff/ServiceWorker/issues/904
Received on Friday, 27 May 2016 08:55:46 UTC