# How to run pre-script with newman?

**URL:** <https://community.postman.com/t/how-to-run-pre-script-with-newman/5973>\
**Category:** Help Hub\
**Created:** [June 19, 2019, 9:24am UTC](https://community.postman.com/t/how-to-run-pre-script-with-newman/5973 "2019-06-19T09:24:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anton39](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@Anton39](https://community.postman.com/u/Anton39)\
**Post date:** [June 19, 2019, 9:24am UTC](https://community.postman.com/t/how-to-run-pre-script-with-newman/5973/1 "2019-06-19T09:24:44Z")

</div>

Hi guys,

I would like to create a pre-script for Postman  
and run it on console with newman.

Do you have any hint, how to do it?  
[https://learning.getpostman.com/docs/postman/scripts/postman\_sandbox\_api\_reference/#pmsendrequest](https://learning.getpostman.com/docs/postman/scripts/postman_sandbox_api_reference/#pmsendrequest)

I saw that it is possible to make an API call, but I would like only to call the pre-script, fetching data and safe the result in external file.

Thanks

---

<div class="post-metadata">

**Author:** ![VincentD123](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/vincentd123/32/1845_2.png) [@VincentD123](https://community.postman.com/u/VincentD123)\
**Post date:** [June 19, 2019, 6:37pm UTC](https://community.postman.com/t/how-to-run-pre-script-with-newman/5973/2 "2019-06-19T18:37:46Z")

</div>

HI @Anton39,  
I’m afraid that the way Postman is implemented means that it doesn’t have access to the local file system, so you can not access a local file to save the response to.  
If you really need to just call an API endpoint and save the result to a file, why not just use node.js and the [fetch method](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)? Node.js scripts have access to the file system and about 12 lines of code should do what you need.  
Let me know if you need any further assistance with that.  
(you will need to install [node-fetch](https://www.npmjs.com/package/node-fetch) from npm)
