How to print json data on console

Overview

You are looking to console.log(โ€œstuffโ€)

A little bit more

If you use console.log, you will always have to modify your script to get rid of it :frowning: since it always runs. Might be better to wrap the log in something.

Simple but powerful change

Use the globals to hold a debug variable so that you can change change it from 0 and 1 depending on if you want to debug. You can setup the value in the collection, folder, or request pre-script too.

Here is what I do

Here is what I usually use in my scripts:

const debug = pm.globals.has("debug") && (pm.globals.get("debug") == 1)

function log(msg){
    debug && msg && console.log(`LOG: ${msg}`)
}

That should give you what you want if you now do this in test for the request:

    const debug = pm.globals.has("debug") && (pm.globals.get("debug") == 1)

    function log(msg){
        debug && msg && console.log(`LOG: ${msg}`)
    }

log(`Here is the json: ${JSON.stringify(pm.response.json())}`)

Whatโ€™s all that && stuff about?

So, the && stuff is part of javascript and others have written about it in the community.
https://community.postman.com/t/sharing-tips-and-tricks-with-others-in-the-postman-community
Look for May 13 '19 and you can find more.