Created
June 12, 2020 00:33
-
-
Save arunesh90/3b0fef2c1c77b106b14ebba9ea26321c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('fetch', event => { | |
event.respondWith(handleRequest(event, event.request)) | |
}) | |
/** | |
* Fetch and log a given request object | |
* @param {Request} request | |
*/ | |
async function handleRequest(event, request) { | |
console.log('Got request', request) | |
const response = await fetch(request) | |
console.log('Got response', response) | |
event.waitUntil( | |
new Promise((resolve) => { | |
setTimeout(() => { | |
console.log('test') | |
resolve() | |
}, 10000) | |
}) | |
) | |
return response | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment