mocko
mocko copied to clipboard
Inspection of Requests and respnse
Great Project. The web version(https://mocko.dev/) lists "Analyze request" as a feature. Was just wondering how to do this. The logs just show the endpoints being hit but does not display the request body or headers etc. Is this to be expected, or perhaps something to work on?
Hey @kgathi2 !
In the future you'll be able to see the request body, headers, parameters in the UI with just a few clicks. For now, you can use the log
helper together with the JSONstringify
helper like so:
{{log "Creating user" request.body.name}}
{{log "Request body:" (JSONstringify request.body)}}
{
"status": "OK"
}
That way, the following request:
Would log this:
For now, the "Logs" tab must be opened for logs to be captured, however, we plan to release persistent logs very soon!
Hope this helps 😄
Oh, forgot to mention, if Content-Type isn't json the request.body
field will be a string and can be logged directly without JSONstringify
@gabriel-pinheiro is it possible to enable "Logs" page in self-hosted version of mocko?