Handled error handling to pre-request script execution
This commit is contained in:
@@ -1,20 +1,22 @@
|
|||||||
export default function getEnvironmentVariablesFromScript(script) {
|
export default function getEnvironmentVariablesFromScript(script) {
|
||||||
let _variables = {}
|
let _variables = {}
|
||||||
|
|
||||||
// the pw object is the proxy by which pre-request scripts can pass variables to the request.
|
try {
|
||||||
// for security and control purposes, this is the only way a pre-request script should modify variables.
|
// the pw object is the proxy by which pre-request scripts can pass variables to the request.
|
||||||
let pw = {
|
// for security and control purposes, this is the only way a pre-request script should modify variables.
|
||||||
environment: {
|
let pw = {
|
||||||
set: (key, value) => (_variables[key] = value),
|
environment: {
|
||||||
},
|
set: (key, value) => (_variables[key] = value),
|
||||||
env: {
|
},
|
||||||
set: (key, value) => (_variables[key] = value),
|
env: {
|
||||||
},
|
set: (key, value) => (_variables[key] = value),
|
||||||
// globals that the script is allowed to have access to.
|
},
|
||||||
}
|
// 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.
|
// run pre-request script within this function so that it has access to the pw object.
|
||||||
new Function("pw", script)(pw)
|
new Function("pw", script)(pw)
|
||||||
|
} catch (_e) {}
|
||||||
|
|
||||||
return _variables
|
return _variables
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user