Watson User Modeling 服务 returns 错误“从 VCAP_SERVICES 读取时无法读取未定义的 属性 '0'
Watson User Modeling service returns error "Cannot read property '0' of undefined when reading from VCAP_SERVICES
Watson User Modeling 服务似乎已从我的应用程序中删除。我的应用程序出现以下错误。
2015-04-09T15:23:38.44-0400 [App/0] ERR /home/vcap/app/lib/config.js:33
2015-04-09T15:23:38.44-0400 [App/0] ERR return vcapServices["user_modeling"][0].credentials.url;
2015-04-09T15:23:38.44-0400 [App/0] ERR ^
2015-04-09T15:23:38.44-0400 [App/0] ERR TypeError: Cannot read property '0' of undefined
2015-04-09T15:23:38.44-0400 [App/0] ERR at Object.watsonUrl (/home/vcap/app/lib/config.js:33:53)
2015-04-09T15:23:38.44-0400 [App/0] ERR at getPersonality (/home/vcap/app/lib/app.js:203:25)
2015-04-09T15:23:38.44-0400 [App/0] ERR at async.waterfall.personalityUser1 (/home/vcap/app/lib/app.js:278:13)
2015-04-09T15:23:38.44-0400 [App/0] ERR at fn (/home/vcap/app/node_modules/async/lib/async.js:641:34)
2015-04-09T15:23:38.44-0400 [App/0] ERR at Object._onImmediate (/home/vcap/app/node_modules/async/lib/async.js:557:34)
2015-04-09T15:23:38.44-0400 [App/0] ERR at processImmediate [as _immediateCallback] (timers.js:345:15)
发生了什么事,我需要做什么来解决这个问题?
最近重命名了用户建模服务。现在是人格洞察力。我通过将新的 Personality Insights 服务添加到我的应用程序并更新我的阅读代码来解决此问题 VCAP_SERVICES.
而不是执行以下操作:
var VCAP_SERVICES = process.env["VCAP_SERVICES"],
vcapServices;
if (VCAP_SERVICES) {
vcapServices = JSON.parse(VCAP_SERVICES);
}
return vcapServices["user_modeling"][0].credentials.url;
改为执行以下操作。注意 user_modeling 与 personality_insights.
有关
var VCAP_SERVICES = process.env["VCAP_SERVICES"],
vcapServices;
if (VCAP_SERVICES) {
vcapServices = JSON.parse(VCAP_SERVICES);
}
return vcapServices["personality_insights"][0].credentials.url;
此外,API 发生了一些变化...URL 现在是您从 VCAP_SERVICES + /v2/profile
获得的 URL。这是 VCAP_SERVICES + /api/v2/profile
更确切地说 vcapServices["personality_insights"][0].credentials.url + "/v2/profile"
。
Watson User Modeling 服务似乎已从我的应用程序中删除。我的应用程序出现以下错误。
2015-04-09T15:23:38.44-0400 [App/0] ERR /home/vcap/app/lib/config.js:33
2015-04-09T15:23:38.44-0400 [App/0] ERR return vcapServices["user_modeling"][0].credentials.url;
2015-04-09T15:23:38.44-0400 [App/0] ERR ^
2015-04-09T15:23:38.44-0400 [App/0] ERR TypeError: Cannot read property '0' of undefined
2015-04-09T15:23:38.44-0400 [App/0] ERR at Object.watsonUrl (/home/vcap/app/lib/config.js:33:53)
2015-04-09T15:23:38.44-0400 [App/0] ERR at getPersonality (/home/vcap/app/lib/app.js:203:25)
2015-04-09T15:23:38.44-0400 [App/0] ERR at async.waterfall.personalityUser1 (/home/vcap/app/lib/app.js:278:13)
2015-04-09T15:23:38.44-0400 [App/0] ERR at fn (/home/vcap/app/node_modules/async/lib/async.js:641:34)
2015-04-09T15:23:38.44-0400 [App/0] ERR at Object._onImmediate (/home/vcap/app/node_modules/async/lib/async.js:557:34)
2015-04-09T15:23:38.44-0400 [App/0] ERR at processImmediate [as _immediateCallback] (timers.js:345:15)
发生了什么事,我需要做什么来解决这个问题?
最近重命名了用户建模服务。现在是人格洞察力。我通过将新的 Personality Insights 服务添加到我的应用程序并更新我的阅读代码来解决此问题 VCAP_SERVICES.
而不是执行以下操作:
var VCAP_SERVICES = process.env["VCAP_SERVICES"],
vcapServices;
if (VCAP_SERVICES) {
vcapServices = JSON.parse(VCAP_SERVICES);
}
return vcapServices["user_modeling"][0].credentials.url;
改为执行以下操作。注意 user_modeling 与 personality_insights.
有关var VCAP_SERVICES = process.env["VCAP_SERVICES"],
vcapServices;
if (VCAP_SERVICES) {
vcapServices = JSON.parse(VCAP_SERVICES);
}
return vcapServices["personality_insights"][0].credentials.url;
此外,API 发生了一些变化...URL 现在是您从 VCAP_SERVICES + /v2/profile
获得的 URL。这是 VCAP_SERVICES + /api/v2/profile
更确切地说 vcapServices["personality_insights"][0].credentials.url + "/v2/profile"
。