-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Async operation before send #158
Comments
Interesting topic, My use-case was that I would like to create a function for cache headers depending of the status code |
There is a way how to do some
module.exports.handler = (event, context, callback) => {
api.run(event, context, callback)
}
api.finally((req, res) => {
saveAudit().finally(() => { console.log('done') })
})
https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html |
api.finally((req, res) ... works great I see that in the handler you can also use then on run
|
I too wish that For now, instead, I keep the pool in a global variable and assign it to the request but clean up in the handler function:
|
Hello everyone!
I need to save some important data every time when the response is already available.
I have tried 2 approaches:
api.finally
- does not allow us to use an async callback.res.send
in a middleware - it looks like the send method can not include any async operations.As a result - the API does not work, but it works if we do not wait for an asynchronous operation.
The text was updated successfully, but these errors were encountered: