Is it possible to use asynchronous functions in/as http handlers? #50
Answered
by
ghost
AlexTolmachev
asked this question in
Q&A
|
This code causes server to terminate: app.get('/*', async (res) => {
res.end(await someFunc());
}); |
Answered by
ghost
Feb 8, 2019
Replies: 5 comments
|
You have two problems here - you can't return from a handler without responding OR attaching an abort handler, just like the message you got says. This message probably needs to be simplified, but it should terminate. Second, it is now possible to use async/await as per last commit, I tested it and it works. |
0 replies
|
This could use an example - AsyncFunction.js or something |
0 replies
|
I have added an example for this. |
0 replies
|
Thanks a lot! It’s very good to see, that library is under active development 🥳 |
0 replies
|
I sure hope so. First "public" release was 5 days ago 😉 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have two problems here - you can't return from a handler without responding OR attaching an abort handler, just like the message you got says. This message probably needs to be simplified, but it should terminate.
Second, it is now possible to use async/await as per last commit, I tested it and it works.