Using the standalone version of Postman, how do I output some debug information in Postman pre-request script?
The code below works great for tests (post-request) but not for pre-request since there is no tests[] array.
var jsonData = JSON.parse(responseBody);
tests["key = " + jsonData.key] = true; // debug message
tests["value = " + jsonData.value] = true; // debug message
Pre-request scripts are a piece of code that will run before the execution of a request. It runs in the Postman sandbox and allows us to add dynamic behavior to request execution.
The only way I could find to accomplish this is by using:
console.log("key = " + key);
console.log("value = " + value);
And then open up the Postman console (Cmd + Option + C / Ctrl + Alt + C) to view the debugs logs in a different window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With