How do I create a client only plugin that adds a property to the client object?

I want to create a plugin that intercepts responses and adds a property to the client object. How do I do it?
1 Reply
Ping
Ping2w ago
You can look into hooks, use an after hook, you can grab the initial value from ctx.context.returned and then return your new obj with ctx.json({...ctx.context.returned, newField: "Hello!"}) Not 100% sure this will work as I'm typing this off the top of my head, but give it a go and LMY if you run into any issues

Did you find this page helpful?