Hey Community,
I had a pre-request script which needs to call “aws-sdk”, as below:
const AWS = require(‘aws-sdk’);
While it reports error: “can’t find ‘aws-sdk’”
I tried to add its cdn as a variable in environment, pls see below two pics
Then added below snippet into pre-request script:
const AWS =pm.environment.get(“aws-sdk”);
(new Function(AWS))();
But it still shows error: SyntaxError: Unexpected token ‘}’
So any suggestions to use aws-sdk in postman pre-request script
Have a look at the following Collection which shows a few methods for consuming external libraries.
https://www.postman.com/postman/workspace/postman-answers/documentation/13455110-7a6c90f0-0062-4089-b206-27c803dc1c37?entity=&branch=&version=
It would appear that you should be using the “Pulling library from a CDN” method using the JavaScript EVAL functionality.
It only really works if the library is fully contained in the CDN.
A lot of these libraries have dependencies on other libraries, and they won’t work.