Skip to content

Instantly share code, notes, and snippets.

@tkdaj
Last active May 3, 2022 21:53
Embed
What would you like to do?
self.addEventListener('fetch', e => {
if(someValue) {
e.respondWith((async () => {
const res = await fetch('my/api');
asyncDecision = await res.text();
return asyncDecision === 'true' ? await fetch('path1') : await fetch(e.request);
})());
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment