You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 31, 2024. It is now read-only.
I am working on a Koa v1 app and would like to implement new routes with async/await instead of generator functions. I found this library has convert.back() which is mostly working for me. However, the following example code will illustrate my problem:
router.get('/endpoint',
async function(next) {
const token = this.request.headers.token;
if (!token) {
this.response.status = 401;
return;
}
// I assume next is a Promise so this is not an issue?
await next;
},
async function(next) {
// This code still executes, even if there is no token defined on the headers.
// Do something important that shouldn't execute with invalid auth...
});
return convert.back(router.routes());
If there is no token defined, the endpoint does return a 401 and exits the first function, but the second function is still executed. If I set up the first function as a generator function and use yield next, it works as would be expected.