Handle response in AdonisJs middleware #1454
-
I'm trying to log all the inbound requests into my database. To do so I've created a Middleware where I fire an event with the data and then a Listener that processes the data and saves it in the db. I'm able to log all the request information but I'm unable to log the response ones. This is my middleware:
The problem is that I don't know how to fire I've tried doing like this:
But nothing happens after the How can I get the response stuff inside this middleware? Adonis version: 4.1 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I'm not sure that the 'finish' event is getting fired on the object you registered it on. class MyMiddleware {
async handle ({response}, next) {
await next()
console.log(response)
}
} |
Beta Was this translation helpful? Give feedback.
I'm not sure that the 'finish' event is getting fired on the object you registered it on.
Maybe you should try debugging it like the snippet below and see what you get.