Reputation: 1407
I use the following lib to be access via code to CF, https://github.com/prosociallearnEU/cf-nodejs-client
what I need to do is to get app for specific space and get the app env
currently i was able to get the all apps but not the env for specific app , any idea what I miss here ? I dont get any informative error to be able to understand what can be missed ...
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);
});
UPDATE
what I need is to get appEnv for specified app (and i've the org & space & App name ), I need that the code will be efficient (performance...) , is my code flow is OK?
Upvotes: 0
Views: 165
Reputation: 1010
Based on your request (get app environment) and the documentation here: cf-nodejs-client v0.13 documentation, it appears that the getEnvirnmentVariables function would give you what you need.
As an alternative, you could do the following:
var cfenv = require('cfenv');
var appEnv = cfenv.getAppEnv();
Upvotes: 1