Get body of the response
I'm trying to get the body of the response through H3.
readBody()
is only for request body. How do I get the one from response?9 Replies
@w7a9q what do you mean with "the reponse body"?
HTTP response body
I got that. but of which response?
Can you show some code
Because at the point when you read the body, it is always the body of the request some client sent to the nitro endpoint
Yeah but you can use middleware to manipulate with the response as well, right? I don't have any code. I want to write a middleware and read the body of the response I return back from endpoint implemented in the
server/api
.ah, so a middleware after handling the request then?
What is the use case if I may ask
The client wants us to verify that the actual response body is JSON.
Plugins - Nitro
Use plugins to extend Nitro's runtime behavior.
check out beforeResponse
Great! Thanks