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:
- copy context as in
ctx2 = ctxand usectx2in the controller - copy context as in
ctx2 = { ...ctx }and usectx2in the controller - read node docs, no reference of a clone method.
- set ctx.body to the body variable being used in the controller
is there anything being overlooked?