in my 1st request under Tests i have the following to get a value and add it as a global variable for later use
var jsonData = pm.response.json();
var workplaceNumbers = [];
jsonData.workplaces.forEach(function(workplace) {
var workplaceNumber = JSON.stringify(workplace.workplaceNumber);
workplaceNumbers.push(workplaceNumber);
});
pm.globals.set("workplaceNumbers", (workplaceNumbers));
and this is an example of what workplaceNumbers saves: “1017703443”
in my 2nd request under Pre-request Script i try to remove the double-quotes, {{workplaceNumbers1}} is part of the Url of this 2nd request and double-quotes are an issue
// "Retrieve the saved "workplaceNumbers" value from the variable"*
var workplaceNumbers = pm.globals.get("workplaceNumbers");
// "Remove the double quotes from the workplaceNumbers value"
var workplaceNumbers1 = workplaceNumbers.replace(/"/g, "");
// "Set the new global variable "workplaceNumbers1"
pm.globals.set("workplaceNumbers1", workplaceNumbers1);
i am stuck here with the following error
There was an error in evaluating the Pre-request Script:TypeError: workplaceNumbers.replace is not a function
Please let me know if there is a better way of doing the above