获取应用程序参数不起作用
Get Application parameters not working
我使用以下库通过代码访问 CF,
https://github.com/prosociallearnEU/cf-nodejs-client
我需要做的是获取特定 space 的应用程序并获取 app env
目前我能够获取所有应用程序但不是特定应用程序的环境,知道我在这里错过了什么吗?我没有收到任何信息性错误,无法理解可能遗漏的内容...
const CloudController = new (require("cf-nodejs-client")).CloudController(endpoint, proxy);
const UsersUAA = new (require("cf-nodejs-client")).UsersUAA;
const Apps = new (require("cf-nodejs-client")).Apps(endpoint, proxy);
const Orgs = new (require("cf-nodejs-client")).Organizations(endpoint, proxy);
CloudController.getInfo()
.then((result) => {
console.log(result);
UsersUAA.setEndPoint(result.authorization_endpoint, proxy);
return UsersUAA.login(username, password);
}).then((result) => {
Apps.setToken(result);
return Apps.getApps();
}).then((result) => {
Apps.setToken(result);
console.log("app guid is: " + result.resources[0].metadata.guid);
return result.resources[0].metadata.guid;
}).then((guid) => {
return Apps.getEnvironmentVariables(guid);
}).then((result) => {
console.log(result);
}).catch((reason) => {
console.error("Error: " + reason);
});
更新
我需要的是为指定的应用程序获取 appEnv(我有组织和 space 和应用程序名称),我需要代码高效(性能...),是我的码流还好吗?
根据您的请求(获取应用程序环境)和此处的文档:cf-nodejs-client v0.13 documentation,getEnvirnmentVariables 函数似乎可以满足您的需求。
作为替代方案,您可以执行以下操作:
var cfenv = require('cfenv');
var appEnv = cfenv.getAppEnv();
我使用以下库通过代码访问 CF, https://github.com/prosociallearnEU/cf-nodejs-client
我需要做的是获取特定 space 的应用程序并获取 app env
目前我能够获取所有应用程序但不是特定应用程序的环境,知道我在这里错过了什么吗?我没有收到任何信息性错误,无法理解可能遗漏的内容...
const CloudController = new (require("cf-nodejs-client")).CloudController(endpoint, proxy);
const UsersUAA = new (require("cf-nodejs-client")).UsersUAA;
const Apps = new (require("cf-nodejs-client")).Apps(endpoint, proxy);
const Orgs = new (require("cf-nodejs-client")).Organizations(endpoint, proxy);
CloudController.getInfo()
.then((result) => {
console.log(result);
UsersUAA.setEndPoint(result.authorization_endpoint, proxy);
return UsersUAA.login(username, password);
}).then((result) => {
Apps.setToken(result);
return Apps.getApps();
}).then((result) => {
Apps.setToken(result);
console.log("app guid is: " + result.resources[0].metadata.guid);
return result.resources[0].metadata.guid;
}).then((guid) => {
return Apps.getEnvironmentVariables(guid);
}).then((result) => {
console.log(result);
}).catch((reason) => {
console.error("Error: " + reason);
});
更新
我需要的是为指定的应用程序获取 appEnv(我有组织和 space 和应用程序名称),我需要代码高效(性能...),是我的码流还好吗?
根据您的请求(获取应用程序环境)和此处的文档:cf-nodejs-client v0.13 documentation,getEnvirnmentVariables 函数似乎可以满足您的需求。
作为替代方案,您可以执行以下操作:
var cfenv = require('cfenv');
var appEnv = cfenv.getAppEnv();