我编写了一个使用 Cloud Endpoints 的 Java App Engine 应用程序。我想从 Node.js 应用程序与这些端点交谈。是否可以为此目的使用 google-api-nodejs-client ?
我已经尝试过这个:
var googleapis = require('googleapis');
googleapis
.discover('myapiname', 'v1dev', {baseDiscoveryUrl: 'http://localhost:8888/_ah/api/discovery/v1/apis/'})
.execute(function(err, client) {
console.log(err);
console.log(client);
client.myapiname.domains.list().execute(function(err, resp) {
console.log(resp);
});
});
但是库没有发现我的端点,回调返回 nullerr
并且client
看起来像这样:
{ clients: [],
ops: {},
authClient: null,
undefined:
{ apiMeta: '<html><head><title>Error 404</title></head>\n<body><h2>Error 404</h2></body>\n</html>',
authClient: null,
defaultParams: null } }
我已经用“myapiname”替换了我的真实 api 名称,当然 URLhttp://localhost:8888/_ah/api/discovery/v1/apis/
是可访问的(如果我在同一台计算机上的浏览器中打开它,它会返回正确的发现 JSON)。