# Can any one let me know why i am getting the below error as undefined

**URL:** <https://community.postman.com/t/can-any-one-let-me-know-why-i-am-getting-the-below-error-as-undefined/15682>\
**Category:** Help Hub\
**Created:** [September 8, 2020, 12:07pm UTC](https://community.postman.com/t/can-any-one-let-me-know-why-i-am-getting-the-below-error-as-undefined/15682 "2020-09-08T12:07:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shota331](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@shota331](https://community.postman.com/u/shota331)\
**Post date:** [September 8, 2020, 12:07pm UTC](https://community.postman.com/t/can-any-one-let-me-know-why-i-am-getting-the-below-error-as-undefined/15682/1 "2020-09-08T12:07:35Z")

</div>

Request body:

```auto
let response = pm.response.json();

pm.environment.set("id", response.id)

pm.environment.set("token", response.createdAt)

pm.test('Verifying the ID Value', function(){

pm.expect(response.id).is.eql(pm.environment.get('id'));

pm.expect(response.createdAt).is.eql(pm.environment.get('token'));

});

console.log(pm.environment.get('id'));

console.log(pm.environment.get(pm.environment.get('token')));

```

Request in Post: `https://reqres.in/api/users`

Respose body:

```auto
{

    "name": "morpheus",
    "job": "leader",
    "id": "808",
    "createdAt": "2020-09-08T11:54:02.679Z"
}

```

I have created 2 environment variable ID and token for ID and Createdat response. Please help me out on this

---

<div class="post-metadata">

**Author:** ![bpricilla](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/bpricilla/32/6511_2.png) [@bpricilla](https://community.postman.com/u/bpricilla)\
**Post date:** [September 18, 2020, 5:38am UTC](https://community.postman.com/t/can-any-one-let-me-know-why-i-am-getting-the-below-error-as-undefined/15682/2 "2020-09-18T05:38:59Z")

</div>

Hello @shota331 you are still having this issue? Usually undefined is displayed when you add the parameters and there is no values defined it under any level (Global, environment etc…)

May be the below blog will be useful:

> **[Using Variables inside Postman and Collection Runner | Postman Blog](https://blog.postman.com/using-variables-inside-postman-and-collection-runner/)**
>
> Harness the power of using variables inside Postman and Collection Runner. Discover how testing hundreds of variations can maximize your Postman workflow.

---

<div class="post-metadata">

**Author:** ![allenheltondev](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/allenheltondev/32/31738_2.png) [@allenheltondev](https://community.postman.com/u/allenheltondev)\
**Post date:** [September 18, 2020, 12:01pm UTC](https://community.postman.com/t/can-any-one-let-me-know-why-i-am-getting-the-below-error-as-undefined/15682/3 "2020-09-18T12:01:05Z")

</div>

I ran the request with the test script you provided. I’m going to guess that you’re just talking about the console log saying undefined.

The blog post that @bpricilla provided will probably help on understanding what variables are. I can’t quite follow what you’re trying to do.

Problems that I see:

- You are trying to grab values that don’t exist
- You are testing that a variable is equal to itself
- You are trying to console log variables that don’t exist.
- There is no `createdAt` property in the response

Here is what I think you’re trying to do:

```auto
const response = pm.response.json();

const ids = _.map(response.data, 'id');
pm.test('Values are returned with Ids', function(){
  pm.expect(ids.length).to.be.at.least(0);

  pm.environment.set('ids', JSON.stringify(ids));
});

console.log(ids);

```
