const fs = require('fs');
let rawdata = fs.readFileSync('path/to/file.json');
let jsonData = JSON.parse(rawdata);
console.log(jsonData);
The fileSystem library is not available in the Postman Sandbox.
You cannot write or read directly to the local filesystem using Postman natively.
See here for what external libraries that Postman supports.
Postman JavaScript reference | Postman Learning Center
You can however, use the collection runner which allow you to iterate over a JSON file or CSV file.
If you don’t want to iterate over the JSON file per se, and just want an object with the JSON contents, then you can add the JSON into a single cell in a CSV file and then retrieve that using the collection runner. (This should work in Newman as well). It’s a workaround of sorts.
Using CSV and JSON Data Files in the Postman Collection Runner | Postman Blog
Retrieving the content from the Internet should work though as that should be just another API call. You haven’t really explained what difficulties are are having in that respect.
This will be down to where you are storing the data and what that API accepts.
Where were you considering storing the data? I assumed you had something in mind, when you mentioned the internet.
For example, a SharePoint list or similar technology.
It will probably be a GET request of some sort.
What headers\authentication that server requires, will down to the API and documentation.
Usually these providers including examples of the requests in their documentation.
If you don’t know how to retrieve data from one API to use in another request, then please go through the Postman Learning Centre.
Introduction | Postman Learning Center
In particular, the core Postman training.
Postman
I would recommend starting with the “Galaxy APIs 101” and “Galaxy Testing and Automation” courses. (The Galaxy APIs has an error on the final submission, which I hope will be fixed at some point in the near future).
Finally, the following will explain how to set and use variables.
Using variables | Postman Learning Center