邮递员-嵌套环境变量 [英] Postman - Nested Environment Variables
问题描述
我正在寻找一种在Postman中制作包含其他变量的环境变量的方法。例如:{Server} = localhost; {Port} = 9200; {ServerUrl} = {Server}:{Port}。
I'm looking for a way to make environment variables in Postman, that contain other variables. For example: {Server}=localhost;{Port}=9200;{ServerUrl}={Server}:{Port}.
类似于Make ...
Like in Make...
这种方式似乎不适用于Postman。
This way it doesn't seem to work with Postman.
编辑:
我的尝试:
My attempt:
推荐答案
您可以执行此操作,但我不推荐这样做,似乎您失去了创建一组变量然后通过选择其他环境文件来更改这些变量的值的好处。
You could do it but I wouldn't recommend it, just seem like you're missing the benefit creating a set of variables and then changing the values of these by selecting a different environment file.
添加此字符串 {{ElasticsearchProtocol}}:// {{ElasticsearchServer}}:{{ElasticsearchPort}}
作为环境文件上的 ElasiticsearchUrl
变量。
Add this string {{ElasticsearchProtocol}}://{{ElasticsearchServer}}:{{ElasticsearchPort}}
as the ElasiticsearchUrl
variable, on the environment file.
或者您可以将其添加到 Pre-Request脚本
:
Or you could add this to the Pre-Request Script
:
let ElasticsearchProtocol = pm.environment.get('ElasticsearchProtocol')
let ElasticsearchServer = pm.environment.get('ElasticsearchServer')
let ElasticsearchPort = pm.environment.get('ElasticsearchPort')
pm.environment.set("ElasticsearchUrl", `${ElasticsearchProtocol}://${ElasticsearchServer}:${ElasticsearchPort}`)
这篇关于邮递员-嵌套环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!