我在circle CI项目中提供了一些环境变量,并使用它的API(https://circleci.com/docs/api/#list-environment-variables)试图获取环境变量的值,但它返回除了最后4位之外的隐藏值(xxxx4134)。我想列出并获取要在我的代码中使用的值,那么如何取消隐藏它或有办法获取正确的值以响应在代码的其他部分中使用?
下面是我在 javascript 中尝试的代码,它确实返回了 env vars 值但被隐藏了。
const options= {
url: 'https://circleci.com/api/v1.1/project/github/projectName/envvar?circle-token={{apiToken}}',
method: 'GET',
json: true,
resolveWithFullResponse: true,
}
request(options).then(response => { console.log('response=', response.body)
for (var count = 0; count < response.body.length; count++) {
var item = response.body[count]
if (item.name == 'C_ID') {
const cId = item.value
}
})
实际 API 调用响应:
"name" : "A_TOKEN",
"value" : "xxxx7177"
}, {
"name" : "C_ID",
"value" : "xxxx51fa"
}]```
Upon using parsed json values, for instance of C_ID i.e; "xxxx51fa" in my other API calls results in error as it doesn't understand xxxx.
Any suggestions or help greatly appreciated.