# The postman can't see the collection response variables

**URL:** <https://community.postman.com/t/the-postman-cant-see-the-collection-response-variables/39367>\
**Category:** Help Hub\
**Tags:** tests, variables, collections\
**Created:** [September 22, 2022, 9:40am UTC](https://community.postman.com/t/the-postman-cant-see-the-collection-response-variables/39367 "2022-09-22T09:40:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nnouh](https://avatars.discourse-cdn.com/v4/letter/n/cab0a1/32.png) [@nnouh](https://community.postman.com/u/nnouh)\
**Post date:** [September 22, 2022, 9:40am UTC](https://community.postman.com/t/the-postman-cant-see-the-collection-response-variables/39367/1 "2022-09-22T09:40:23Z")

</div>

hello,  
I have a problem that I declared collection variables to retrieve the response code and text ((pm.response.code ) & (pm.response.text()) by test script. but after sending the request an error appears ( **ReferenceError: resp is not defined** )

 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/3/35dc2fb8c541edbbb72825639f3e19a1430e64df.png)  
 ![image](https://us1.discourse-cdn.com/getpostman/original/2X/2/2761be72b24371500f39e61249d3fd647c2332f4.png)

although it works good with header variables  
thanks in advance

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [September 22, 2022, 5:18pm UTC](https://community.postman.com/t/the-postman-cant-see-the-collection-response-variables/39367/2 "2022-09-22T17:18:53Z")

</div>

You have collection level variables that are pointing to pm.response.xxxx

pm.response is the response of a particular request, you can’t have this on a collection variable.

You have to set those variables using set or get.

```auto
pm.collectionVariables.set(“myVar”, pm.response.code);
console.log(pm.CollectionVariables.get("myVar"));

```

> **[Using variables | Postman Learning Center](https://learning.postman.com/docs/sending-requests/variables/)**
>
> Using variables: documentation for Postman, the collaboration platform for API development. Create better APIs—faster.

If you want to test against the response code, then you just need to put this in your test. Not sure why you would need to save this into a variable.

```auto
{pm.expect(pm.response.code).to.eql(400)}

```
