# Concat ENV variables on the ENV Page

**URL:** <https://community.postman.com/t/concat-env-variables-on-the-env-page/24949>\
**Category:** Help Hub\
**Tags:** environments\
**Created:** [June 17, 2021, 1:45am UTC](https://community.postman.com/t/concat-env-variables-on-the-env-page/24949 "2021-06-17T01:45:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chapman-cheng](https://avatars.discourse-cdn.com/v4/letter/c/a6a055/32.png) [@chapman-cheng](https://community.postman.com/u/chapman-cheng)\
**Post date:** [June 17, 2021, 1:45am UTC](https://community.postman.com/t/concat-env-variables-on-the-env-page/24949/1 "2021-06-17T01:45:13Z")

</div>

My Env includes:  
DOMAIN: [example.com](http://example.com)  
PORT: 8008  
BASE\_API: info/api

How do I create persist an concatenated variable in the ENV table, e.g.  
https://$DOMAIN:$PORT/$BASE\_API/  
(curly braces and

I can do concatenation in pre-request-script, e.g. pm.environment.set(“FULL\_PATH”, https://$DOMAIN… )  
but doing so the script-base-variable doesn’t show the resolved value to the variable but just e.g. {{FULL\_PATH}}user-login/

is there a way to fix this?

---

<div class="post-metadata">

**Author:** ![pranavdavar](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/pranavdavar/32/9152_2.png) [@pranavdavar](https://community.postman.com/u/pranavdavar)\
**Post date:** [June 17, 2021, 12:04pm UTC](https://community.postman.com/t/concat-env-variables-on-the-env-page/24949/2 "2021-06-17T12:04:45Z")

</div>

Hi @chapman-cheng, Welcome to the community!

As per your use case you can try using variables like below.

`https://{{host}}:{{port}}/{{base_api}}/{{relative_api}}`

Then, host, port, base\_api, relative\_api can be set in environment variables.

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![kevin.swiber](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/kevin.swiber/32/3820_2.png) [@kevin.swiber](https://community.postman.com/u/kevin.swiber)\
**Post date:** [June 18, 2021, 2:01am UTC](https://community.postman.com/t/concat-env-variables-on-the-env-page/24949/3 "2021-06-18T02:01:42Z")

</div>

Hi @chapman-cheng,

To add on to what @pranavdavar said, you can actually use variables inside of other variables! In addition to variables for URL parts like `host`, `port`, and `path`, you can have another variable named `url` with the value `https://{{host}}:{{port}}/{{path}}` Then in your request, you can use `{{url}}`, and it will resolve correctly.

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

To accomplish this in a script, you can use the `pm.variables.replaceIn` method.

Example:

```js
const url = pm.variables.replaceIn('https://{{host}}:{{port}}/{{path}}');
console.log(url);

```

Console output:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/d/a/da37944e236674727d315f5862204f2df9ab3dba.png)
