cloudflare / cloudflare/template-registry

Question: why async?

Open
#14 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
62
Forks
28
PR merge metrics
No merged PRs in 30d

Description

In this simple redirect example why are there async functions?

https://github.com/victoriabernard92/template-registry/blob/master/templates/javascript/redirect.js#L1

This could be re-written without the async keywords and appears to work the same.

```javascript
function handleRequest(request) {
return Response.redirect(someURLToRedirectTo, code)
}
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
/**
* Example Input
* @param {Request} url where to redirect the response
* @param {number?=301|302} type permanent or temporary redirect
*/
const someURLToRedirectTo = 'https://www.google.com'
const code = 301
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.