Changes for page LiveTableServiceWorker
Last modified by bougault on 2022/03/22 17:19
Summary
-
Objects (1 modified, 0 added, 0 removed)
Details
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -6,19 +6,17 @@ 6 6 7 7 self.addEventListener("activate" , event => { 8 8 // console.log(event); 9 - clients.claim(); 10 - //event.waitUntil(clients.claim());9 +// clients.claim(); 10 + event.waitUntil(clients.claim()); 11 11 }); 12 12 13 -self.addEventListener("fetch" , async (event) => { 14 - 13 +self.addEventListener("fetch" , event => { 15 15 const pathname = new URL(event.request.url).pathname; 16 - console.log(pathname); 17 17 if(pathname === '/bin/get/XWiki/LiveTableResults') { 18 - constres= awaitfetch(event.request);19 - const json=res.json();20 - 21 - json ['hello']= 'Hello';22 - event.respondWith(json);16 + event.respondWith(fetch(event.request).then(res => res.json()).then(json => { 17 + const headers = new Headers({'Content-Type': 'application/json'}); 18 + const jsonResults = json.rows.filter(row => row.doc_viewable === true); 19 + return new Response(JSON.stringify(jsonResults), {headers}); 20 + })); 23 23 } 24 24 });