I am trying to log request data from an API endpoint to ensure we have periodic backups for when the database crashes in between backup intervals. A logging hook has been created and attached to the controller where I access the Context
variable as ctx
. I have been able to access the request user through ctx.user
but the body is undefined whenever I try to access it through ctx.request.body
To my knowledge vanilla JS requests have a .clone()
method that clones the request
because the request body is destroyed on use. My approach is to make a hook that logs the data in a file and writes to disk but so far the body showing up empty in the logging hook.
attempts to resolve:
ctx2 = ctx
and use ctx2
in the controllerctx2 = { ...ctx }
and use ctx2
in the controlleris there anything being overlooked?
It looks like you're accessing the request body using the wrong key.
The request body is accessible through ctx.request.body
and not ctx.body
. 👍