# Newman library in node.js script: access iterationData value for each iteration cycle

**URL:** <https://community.postman.com/t/newman-library-in-node-js-script-access-iterationdata-value-for-each-iteration-cycle/17564>\
**Category:** Help Hub\
**Tags:** newman-project, library\
**Created:** [November 10, 2020, 1:06pm UTC](https://community.postman.com/t/newman-library-in-node-js-script-access-iterationdata-value-for-each-iteration-cycle/17564 "2020-11-10T13:06:14Z")\
**Posts on this page:** 1\
**Showing post:** 8

<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 10, 2020, 4:59pm UTC](https://community.postman.com/t/newman-library-in-node-js-script-access-iterationdata-value-for-each-iteration-cycle/17564/8 "2020-11-10T16:59:32Z")

</div>

I tried to answer that here:

> [@Save response in CSV file via newman](https://community.postman.com/t/save-response-in-csv-file-via-newman/15508/7):
>
> It looks like using Newman as a library, rather than from the command line with a specific reporter is going to be the option here. You can tap into the different events and extract the data you want from the response and feed this into a CSV file. The node ‘fs’ module will allow you to write the data into a file. [https://nodejs.org/api/fs.html](https://nodejs.org/api/fs.html) Just a hacky example piece of code and is not a finished or polished solution: const newman = require('newman'), fs = require('fs') newman.…

The only thing that you would need to change is the way you get the values from the data field during the different iterations:

```auto
let fieldOne = pm.iterationData.get('field1'),
    fieldTwo = pm.iterationData.get('field2');

console.log(`\n${fieldOne},${fieldTwo}`)

```

---

_[View the full topic](https://community.postman.com/t/newman-library-in-node-js-script-access-iterationdata-value-for-each-iteration-cycle/17564)._
