mocko icon indicating copy to clipboard operation
mocko copied to clipboard

Inspection of Requests and respnse

Open kgathi2 opened this issue 3 years ago • 3 comments

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?

kgathi2 avatar Oct 18 '21 15:10 kgathi2

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"
}

mock creation

That way, the following request: request

Would log this: logs

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 😄

gabriel-pinheiro avatar Oct 18 '21 16:10 gabriel-pinheiro

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 avatar Oct 18 '21 16:10 gabriel-pinheiro

@gabriel-pinheiro is it possible to enable "Logs" page in self-hosted version of mocko?

Sirozha1337 avatar Dec 28 '21 14:12 Sirozha1337