Created
April 11, 2018 10:44
-
-
Save vdespa/8b2d209867cc10e40939b0ce3696e3c8 to your computer and use it in GitHub Desktop.
Newman - Logging request and response body
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
👍