N
Nuxt5mo ago
w7a9q

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
manniL
manniL5mo ago
@w7a9q what do you mean with "the reponse body"?
w7a9q
w7a9qOP5mo ago
HTTP response body
manniL
manniL5mo ago
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
w7a9q
w7a9qOP5mo ago
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.
manniL
manniL5mo ago
ah, so a middleware after handling the request then? What is the use case if I may ask
w7a9q
w7a9qOP5mo ago
The client wants us to verify that the actual response body is JSON.
manniL
manniL5mo ago
Plugins - Nitro
Use plugins to extend Nitro's runtime behavior.
manniL
manniL5mo ago
check out beforeResponse
w7a9q
w7a9qOP5mo ago
Great! Thanks
Want results from more Discord servers?
Add your server