pre-request script working

This commit is contained in:
Nicholas Palenchar
2019-10-29 21:28:44 -04:00
parent 0647fc3297
commit 668f99c37f
4 changed files with 100 additions and 39 deletions

17
functions/preRequest.js Normal file
View File

@@ -0,0 +1,17 @@
export default function getEnvironmentVariablesFromScript(script) {
let _variables = {};
// the pw object is the proxy by which pre-request scripts can pass variables to the request.
// for security and control purposes, this is the only way a pre-request script should modify variables.
let pw = {
environment: {
set: (key, value) => _variables[key] = value,
},
// globals that the script is allowed to have access to.
};
// run pre-request script within this function so that it has access to the pw object.
(new Function('pw', script))(pw);
return _variables;
}