I want to automatically add a header to every request in my whole collection using this pre-request script:
pm.request.headers.add({
\'key\': \"myvar\",
This copied from here, but it worked for me
https://gist.github.com/madebysid/b57985b0649d3407a7aa9de1bd327990
pm.sendRequest({
url: "https://mydomain/ers/config/endpoint",
method: 'GET',
header: {
'content-type': 'application/json',
'accept': 'application/json',
//'x-site-code': pm.environment.get("x-site-code")
'X-CSRF-TOKEN': 'fetch'
},
body: {
mode: 'raw'//,
raw: JSON.stringify({ email: pm.environment.get("email"), password: pm.environment.get("password") })
}
}, function (err, res) {
pm.environment.set("X-CSRF-TOKEN", "Bearer " + res.json().token);
});