Hello,
i use the following javascript code to fetch the x-csrf-token from a server.
In postman the value is showed in the header response.
How can i access the response header using javascript. How can i get the x-csrf-token value and save it in a variable to be reused?
function test2(){
var myHeaders = new Headers();
myHeaders.append("x-csrf-token", "FETCH");
myHeaders.append("Authorization", "Basic FrtZTRIUZUIJIBHxOTpJTklUMTI=");
myHeaders.append("Cookie", "MYSAPSSO2=AjQxMDMBABhIADYAMgA0ADIAMQA5ACAAIkrnknkNKNNUBJACAAIAAgACAABAAYMgAwADIAMUHIKOKMNHVGVEANgA0ADEABQAEAAAACAYAAlgACQACRQD%2fAVcwggFTBgkqhkiG9w0BBwKgggFEMIIBQAIBATELMAkGBSsOAwIaBQAwCwYJKoZIhvcNAQcBMYIBHzCCARsCAQEwcDBkMQswCQYDVQQGEwJERTEcMBoGA1UEChMTU0FQDExMlowIwYJKoZIhvcNAQkEMRYEFBmtYzRqKDP0yD3GOybxG3tQpDFBMAkGByqGSM44BAMELzAtAhUAkNZaJuhVl9GD4I0e9gIAsrnYlCICFAmG%218eYZgS0whq6D3UOzzJFMVdR");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://odataServer.de", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
}
Thanks.