I am currently syncing cookies from chrome using interceptor to postman and I can see the cookies being available in the postman. Let say the url is example.com to the website which is having 2 cookies XSRF-TOKEN and Authenticationtoken.
If I want to make a request to the api, I have to send the cookies along with that as a header XSRF-TOKEN must be passed with the name X-XSRF-TOKEN.
Since the cookies are already synced, I am trying to fetch the cookie and set it as environment variable so that the same can be utilized in the headers but unfortunately, the cookie value is not available in Pre-request Script but is available in Test.
var xsrfToken = pm.cookies.get("XSRF-TOKEN");
if (xsrfToken) {
pm.environment.set("XSRFCookie", xsrfToken);
console.log("XSRF Token stored:", xsrfToken);
} else {
console.log("XSRF Token not found");
}
Can someone try to help me set this environment variable? My end motive is to use this collection in Runner.