Skip to content

Instantly share code, notes, and snippets.

@arunesh90
Created June 12, 2020 00:33
Show Gist options
  • Save arunesh90/3b0fef2c1c77b106b14ebba9ea26321c to your computer and use it in GitHub Desktop.
Save arunesh90/3b0fef2c1c77b106b14ebba9ea26321c to your computer and use it in GitHub Desktop.
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