1

似乎 Watson 用户建模服务已从我的应用程序中删除。我在我的应用程序中收到以下错误。

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)

发生了什么,我需要做什么来解决这个问题?

4

1 回答 1

3

用户建模服务最近已重命名。现在是个性洞察。我通过将新的 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 现在是您从中获取的 URL VCAP_SERVICES + /v2/profile。它是VCAP_SERVICES + /api/v2/profile

更确切地说vcapServices["personality_insights"][0].credentials.url + "/v2/profile"

于 2015-04-09T20:51:06.013 回答