Watson用户build模服务返回错误“从VCAP_SERVICES读取时,不能读取未定义的属性'0'

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

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) 

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

用户build模服务最近重命名。 现在是个人见解。 我通过将新的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"