Skip to content

Instantly share code, notes, and snippets.

@iqbmo04
Forked from vdespa/writeToDisk.js
Created January 17, 2024 14:08
Show Gist options
  • Save iqbmo04/acff2eeb820ad777503f2529d070d60c to your computer and use it in GitHub Desktop.
Save iqbmo04/acff2eeb820ad777503f2529d070d60c to your computer and use it in GitHub Desktop.
Newman - Logging request and response body
const newman = require('newman');
newman.run({
collection: require('./postman_collection.json'),
reporters: 'cli'
}).on('beforeRequest', function (error, args) {
if (error) {
console.error(error);
} else {
// Log the request body
console.log(args.request.body.raw);
}
}).on('request', function (error, args) {
if (error) {
console.error(error);
}
else {
// Log the response body
console.log(args.response.stream.toString());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment