【发布时间】:2017-05-18 17:28:33
【问题描述】:
我使用下面的lib来连接云控制器
https://github.com/prosociallearnEU/cf-nodejs-client
const endpoint = "https://api.mycompany.com/";
const username = "myuser";
const password = "mypass";
const CloudController = new (require("cf-client")).CloudController(endpoint);
const UsersUAA = new (require("cf-client")).UsersUAA;
const Apps = new (require("cf-client")).Apps(endpoint);
CloudController.getInfo().then((result) => {
UsersUAA.setEndPoint(result.authorization_endpoint);
return UsersUAA.login(username, password);
}).then((result) => {
Apps.setToken(result);
return Apps.getApps();
}).then((result) => {
console.log(result);
}).catch((reason) => {
console.error("Error: " + reason);
});
我尝试针对我们的 API 运行它,但它不起作用,我在控制台中没有收到任何错误消息,它可能是什么?
这里的空间/组织在哪里处理?因为当我从 cli 连接时,它会询问我要连接到哪个空间/组织...
我能够通过 CLI 登录,仅通过 我无法访问的代码,知道这里缺少什么吗?
我运行它时的问题我没有收到任何有助于了解根本原因的错误
【问题讨论】:
-
您使用的端点是什么?我刚刚使用api.ng.bluemix.net(Bluemix 端点)尝试了您的代码,它运行良好。
-
@AlexdaSilva - API 是我的公司 API,但在我能够在 CLI 中连接之前,我使用代理 ...比如 https_proxy=mycompany.corp:8080 ,我认为这个库不支持这个...
-
API 不支持代理。我查看了代码,它使用请求模块,但没有设置代理的选项。您必须添加代理支持或在 github 中打开问题请求它。
标签: javascript node.js ibm-cloud cloud-foundry