Skip to content

Commit

Permalink
Update samples
Browse files Browse the repository at this point in the history
  • Loading branch information
Arshia001 committed Nov 6, 2023
1 parent 8861301 commit af8fe47
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/fetch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
addEventListener('fetch', async req => {
req.respondWith(await handleRequest(req));
addEventListener('fetch', req => {
req.respondWith(handleRequest(req));
});

async function handleRequest(req) {
Expand Down
12 changes: 8 additions & 4 deletions tests/promise.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@

addEventListener('fetch', async req => {
async function handleRequest(req) {
await sleep(1000);
req.respondWith(new Response('hello'));
});
return new Response('hello');
}

const sleep = n => new Promise(resolve => setTimeout(resolve, n));
const sleep = n => new Promise(resolve => setTimeout(resolve, n));

addEventListener('fetch', req => {
req.respondWith(handleRequest(req));
});
7 changes: 5 additions & 2 deletions tests/simple.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
async function handleRequest(req) {
return new Response('hello');
}

addEventListener('fetch', (req) => {
req.respondWith(new Response('hello'));
addEventListener('fetch', req => {
req.respondWith(handleRequest(req));
});

0 comments on commit af8fe47

Please sign in to comment.