cloudflare / cloudflare/template-registry
Question: why async?
- 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
Assessment
This issue has not been assessed yet.