# How to Save Get response to local file?

**URL:** <https://community.postman.com/t/how-to-save-get-response-to-local-file/17942>\
**Category:** Help Hub\
**Tags:** newman-project\
**Created:** [November 22, 2020, 1:44pm UTC](https://community.postman.com/t/how-to-save-get-response-to-local-file/17942 "2020-11-22T13:44:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bukhari.adac](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bukhari.adac](https://community.postman.com/u/bukhari.adac)\
**Post date:** [November 22, 2020, 1:44pm UTC](https://community.postman.com/t/how-to-save-get-response-to-local-file/17942/1 "2020-11-22T13:44:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [November 22, 2020, 2:04pm UTC](https://community.postman.com/t/how-to-save-get-response-to-local-file/17942/2 "2020-11-22T14:04:56Z")

</div>

Hey @bukhari.adac

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. 😁

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

```auto
const newman = require('newman'),
      fs = require('fs');

newman.run({
  collection: '<Postman Collection>'
}).on('request', (err, args) => {
  fs.writeFile(`./results/${args.item.name}.json`, args.response.stream, (err) => {
    if (err) { 
        console.error(err); 
    }
  });
})

```

---

<div class="post-metadata">

**Author:** ![bukhari.adac](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bukhari.adac](https://community.postman.com/u/bukhari.adac)\
**Post date:** [November 24, 2020, 3:57am UTC](https://community.postman.com/t/how-to-save-get-response-to-local-file/17942/3 "2020-11-24T03:57:01Z")

</div>

Thank you @danny-dainton for your help.
