# Console Response Header Value, How to Retrieve?

**URL:** <https://community.postman.com/t/console-response-header-value-how-to-retrieve/26207>\
**Category:** Help Hub\
**Created:** [July 27, 2021, 6:53pm UTC](https://community.postman.com/t/console-response-header-value-how-to-retrieve/26207 "2021-07-27T18:53:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![univashu](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/univashu/32/9272_2.png) [@univashu](https://community.postman.com/u/univashu)\
**Post date:** [July 27, 2021, 6:53pm UTC](https://community.postman.com/t/console-response-header-value-how-to-retrieve/26207/1 "2021-07-27T18:53:25Z")

</div>

_My question_: The API, I am working with has been coded in a way that the TOKEN which I want does not appears in the body or headers section. Instead it comes in console under Response Header. How can I get that value?

_Details (like screenshots)_:

 ![Postman Console](https://us1.discourse-cdn.com/getpostman/original/2X/1/11364985e340136c0581e868479b5003375bb85a.png)

_I’ve already tried_: I have looked around a lot of things but couldnt find any solution. Would be really glad if anyone can assist in that.

All I want is to fetch the sssToken store it and use in other headers.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [July 27, 2021, 9:46pm UTC](https://community.postman.com/t/console-response-header-value-how-to-retrieve/26207/2 "2021-07-27T21:46:05Z")

</div>

Hey @univashu

You can use this to get the full value of the header and then split it on the `=` character:

```auto
console.log(pm.response.headers.get('Location').split('='));

```

From that you will see an array of values and it will be the last one 🤔

---

<div class="post-metadata">

**Author:** ![univashu](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/univashu/32/9272_2.png) [@univashu](https://community.postman.com/u/univashu)\
**Post date:** [July 28, 2021, 7:26am UTC](https://community.postman.com/t/console-response-header-value-how-to-retrieve/26207/3 "2021-07-28T07:26:15Z")

</div>

I tried that but its coming as undefined.

Just to give you more clear picture please refer the below screenshots.

 ![Postman 1](https://us1.discourse-cdn.com/getpostman/original/2X/a/a82fb371d6f6bcbb9ecf11f4941cd9acd64a9f32.png)  
 ![Postman 2](https://us1.discourse-cdn.com/getpostman/original/2X/8/8648080255b45f4290c556cd20defce318657d04.png)

The command you shared fetches the value from header which is in response but I need to fetch value from console header. I hope I am making sense.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [July 28, 2021, 7:52am UTC](https://community.postman.com/t/console-response-header-value-how-to-retrieve/26207/4 "2021-07-28T07:52:41Z")

</div>

It looks like that original request is redirected (302 status) to a different URL which contains the `Location` header. That information wasn’t part of the original questions and missing the the cropped image.

As that code snippet is in the original request, the `Location` header isn’t part of that response - that’s why it’s _undefined_

---

<div class="post-metadata">

**Author:** ![univashu](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/univashu/32/9272_2.png) [@univashu](https://community.postman.com/u/univashu)\
**Post date:** [July 28, 2021, 8:04am UTC](https://community.postman.com/t/console-response-header-value-how-to-retrieve/26207/5 "2021-07-28T08:04:36Z")

</div>

Yes, I am sorry I missed that part. But is there any way I can fetch that particular value?

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [July 28, 2021, 9:23am UTC](https://community.postman.com/t/console-response-header-value-how-to-retrieve/26207/6 "2021-07-28T09:23:36Z")

</div>

This might work but I’m not confident 😕

If you go to settings and disable “Automatically follow redirects”, then add this to the `Tests`:

```auto
const querystring = require('querystring');

let params = pm.response.headers.get('Location').split('?')

console.log(querystring.parse(`${_.last(params)}`).sssToken)

```

It’s probably not what you need as it wouldn’t complete the flow you need - I’m unsure have to get the headers from a redirected URL in an efficient way ☹

---

<div class="post-metadata">

**Author:** ![fais2021](https://avatars.discourse-cdn.com/v4/letter/f/9f8e36/32.png) [@fais2021](https://community.postman.com/u/fais2021)\
**Post date:** [August 27, 2021, 1:12pm UTC](https://community.postman.com/t/console-response-header-value-how-to-retrieve/26207/7 "2021-08-27T13:12:09Z")

</div>

Were you able to retrieve value from console, do you mind share your solution?

---

<div class="post-metadata">

**Author:** ![univashu](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/univashu/32/9272_2.png) [@univashu](https://community.postman.com/u/univashu)\
**Post date:** [August 27, 2021, 1:34pm UTC](https://community.postman.com/t/console-response-header-value-how-to-retrieve/26207/8 "2021-08-27T13:34:33Z")

</div>

Not really from console header but turning off Automatic redirect helped me.  
As due to that I was able to pick the value from initail request.

---

<div class="post-metadata">

**Author:** ![fais2021](https://avatars.discourse-cdn.com/v4/letter/f/9f8e36/32.png) [@fais2021](https://community.postman.com/u/fais2021)\
**Post date:** [August 27, 2021, 10:15pm UTC](https://community.postman.com/t/console-response-header-value-how-to-retrieve/26207/9 "2021-08-27T22:15:39Z")

</div>

Thank you, I will try that way.

---

<div class="post-metadata">

**Author:** ![ovoutat](https://avatars.discourse-cdn.com/v4/letter/o/73ab20/32.png) [@ovoutat](https://community.postman.com/u/ovoutat)\
**Post date:** [April 25, 2024, 9:42am UTC](https://community.postman.com/t/console-response-header-value-how-to-retrieve/26207/10 "2024-04-25T09:42:54Z")

</div>

I have a similar problem, but disabling automatic redirect doesn’t work for me because I have a double redirect and the data that I want is in second get or in the final 200 get request url

 ![2024-04-25 11_41_16-Postman Console](https://us1.discourse-cdn.com/getpostman/original/3X/a/3/a3a9adff548e50dbbd68087745562068fb5b52f1.png)
