|
|
|
|
|
by simonw
1519 days ago
|
|
Question about https://edge-functions-examples.netlify.app/example/rewrite export default async (request: Request, context: Context) => {
return context.rewrite("/something-to-serve-with-a-rewrite");
};
I'm surprised that the function is async but context.rewrite() doesn't use an await. Is that because the rewrite is handed back off to another level of the Netlify stack to process? |
|
Using async for functions that do not use await is still a good idea because thrown errors are converted to rejected promises.
`return await` can be useful because it's a signal that the value is async, causes the current function to be included in the async stack trace, and completes local try/catch/finally blocks when the promise resolves