# Show content of variable in console log

**URL:** <https://community.postman.com/t/show-content-of-variable-in-console-log/21273>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [March 11, 2021, 1:06pm UTC](https://community.postman.com/t/show-content-of-variable-in-console-log/21273 "2021-03-11T13:06:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![beegee3235](https://avatars.discourse-cdn.com/v4/letter/b/7993a0/32.png) [@beegee3235](https://community.postman.com/u/beegee3235)\
**Post date:** [March 11, 2021, 1:06pm UTC](https://community.postman.com/t/show-content-of-variable-in-console-log/21273/1 "2021-03-11T13:06:32Z")

</div>

Hi there

I like to have an output of a created variable who is actually using the result of another variable but i do not get the value that i want in the console log. I already tried with 2 different variables but then i receive both values in the following format “Test-” “1234”.

**Here is what i have in me pre-request script:**

pm.environment.set(“transactionIdNr”, pm.variables.replaceIn(‘{{$timestamp}}’));  
pm.environment.set(“transactionId”, “Test-{{transactionIdNr}}”);

console.log(pm.environment.get(‘transactionId’));

**And here is what i get:**

Test-{{transactionIdNr}}

**I would expect:**

Test-1615466972

In the request body himself, i got the right value of the variable, the issue is just to get it in the console!

Thanks a lot for your help

Greetings BeeGee

**Your question may already have an answer on the community forum. Please search for related topics, and then read through the [guidelines](https://community.postman.com/t/about-the-just-getting-started-category/37) before creating a new topic.**

---

<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:** [March 11, 2021, 1:32pm UTC](https://community.postman.com/t/show-content-of-variable-in-console-log/21273/2 "2021-03-11T13:32:43Z")

</div>

Hey @beegee3235 👋

As you’re saving the environment variable as a `string`, directly logging that variable to the console, will display that `string` value.

```auto
pm.environment.set(“transactionId”, “Test-{{transactionIdNr}}”);

```

The request body is resolving the environment variable correctly, as that already knows how to handle the `{{}}` syntax that’s part of that `string`.

To log the correctly resolved environment value, you can use the same `.replaceIn()` method that you used to set the `{{$timestamp}}` value.

```auto
console.log(pm.environment.replaceIn('{{transactionId}}'));

```

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/7/b/7b1f7f4b00c0672b98e52716a843db3db1c3244a.png)

---

<div class="post-metadata">

**Author:** ![beegee3235](https://avatars.discourse-cdn.com/v4/letter/b/7993a0/32.png) [@beegee3235](https://community.postman.com/u/beegee3235)\
**Post date:** [March 17, 2021, 6:54am UTC](https://community.postman.com/t/show-content-of-variable-in-console-log/21273/3 "2021-03-17T06:54:31Z")

</div>

Thanks Danny!

Works perfectly well!

You’re such a help!

Have a good day!

Greetings Benjamin
