How to Save Get response to local file?

I have Get request without Body. How to save response (json) to a local file using newman?


This is a very common question and doing a quick search in the forum would have returned a few different ways of writing those to file. :grin:

Using Newman as a library and paring that with the Node fs module you can save the responses to a file like this:

const newman = require('newman'),
      fs = require('fs');{
  collection: '<Postman Collection>'
}).on('request', (err, args) => {
  fs.writeFile(`./results/${}.json`,, (err) => {
    if (err) { 
1 Like

Thank you @dannydainton for your help.

1 Like