Authorisation call with cookie-jar

{

const authourizationUrl = `my_url`;
  
  
    const jar = http.cookieJar();
  
    jar.set(authourizationUrl, sessionCookieName, sessionCookieValue); //set cookies from autherization call in the jar
  
    const r2 = http.get(authourizationUrl, { jar: jar, redirects: 0 });
  
  
    for (const value in r2.headers) {
      if (r2.headers.hasOwnProperty(value)) {
        console.log(`${value}: ${r2.headers[value]}`);
      }
    }
  
    new Map(Object.entries(r2.cookies)).forEach((v2, k2) => {
      logCookie(v2[0]);
    });
  
    check(r2, {
      'authorize call has status 302': (r) => r2.status === 302,   //pass
      "authorize call response is not null": r2 => r2.headers != null,   //pass
    });
    
    console.log(`status 302 expected, got -->: ${r2.status}`); //302 as expected
    console.log(`headers location is: ${r2.headers.Location}`);  //logged the location header
    console.log(`headers location code is: ${r2.headers.Location.code}`); // undefined. authorizationCode is not present in the response headers

}

I am not sure exactly what your question is, considering you just dumped a bunch of code with no explanation or anything :sweat_smile: But if I go by the code comments, this seems to be the problem, right?

    console.log(`headers location code is: ${r2.headers.Location.code}`); // undefined. authorizationCode is not present in the response headers

If so, I am not sure what this code you are expecting is, but r2.headers.Location is a string, it doesn’t (and can’t) have a code property :confused: What exactly do you want to achieve?