# How to copy all the responses from postman into a file

**URL:** <https://community.postman.com/t/how-to-copy-all-the-responses-from-postman-into-a-file/14187>\
**Category:** Help Hub\
**Tags:** newman-project, tests, variables, collections\
**Created:** [July 15, 2020, 7:47pm UTC](https://community.postman.com/t/how-to-copy-all-the-responses-from-postman-into-a-file/14187 "2020-07-15T19:47:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sujithkumar.matharas](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@sujithkumar.matharas](https://community.postman.com/u/sujithkumar.matharas)\
**Post date:** [July 15, 2020, 7:47pm UTC](https://community.postman.com/t/how-to-copy-all-the-responses-from-postman-into-a-file/14187/1 "2020-07-15T19:47:59Z")

</div>

I have a curl command which i am running in postman, i pass a variable with 2 values and i am using the “Write Responses To File” method to get the output in a json file. However when i run my code in collection runner the 2 value data gets override by the 1 value data. Can someone help me with how to not override the data in the file and keep appending to the existing? Below is the code i have in my tests where its generating the file

// The opts for the server, also includes the data to be written to file

let opts = {

```
requestName: request.name || request.url,

fileExtension: 'json',

mode: 'writeFile', // Change this to any function of the fs library of node to use it.

uniqueIdentifier: 'waddup',

responseData: pm.response.text()

```

};

pm.sendRequest({

```
url: 'http://localhost:3000/write',

method: 'POST',

header: 'Content-Type:application/json',

body: {

    mode: 'raw',

    raw: JSON.stringify(opts)

}

```

}, function (err, res) {

```
console.log(res);

```

});

---

<div class="post-metadata">

**Author:** ![SabriH](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@SabriH](https://community.postman.com/u/SabriH)\
**Post date:** [July 15, 2020, 8:11pm UTC](https://community.postman.com/t/how-to-copy-all-the-responses-from-postman-into-a-file/14187/2 "2020-07-15T20:11:37Z")

</div>

Hi @sujithkumar.matharas,

Welcome to the Community 👋.

As noted here:  
`mode: 'writeFile', // Change this to any function of the fs library of node to use it.`

You should be able to change this to any function of the fs library of node. Have you tried `appendFile` instead?

[https://nodejs.org/api/fs.html#fs\_fs\_appendfile\_path\_data\_options\_callback](https://nodejs.org/api/fs.html#fs_fs_appendfile_path_data_options_callback)

---

<div class="post-metadata">

**Author:** ![sujithkumar.matharas](https://avatars.discourse-cdn.com/v4/letter/s/73ab20/32.png) [@sujithkumar.matharas](https://community.postman.com/u/sujithkumar.matharas)\
**Post date:** [July 15, 2020, 8:20pm UTC](https://community.postman.com/t/how-to-copy-all-the-responses-from-postman-into-a-file/14187/3 "2020-07-15T20:20:39Z")

</div>

Thanks a lot Sabri, as i am new to this i didnt knew that. That is what exactly what i was looking for. Thank you for your help.
