node.js - Watson User Modeling service returns error "Cannot read property '0' of undefined when reading from VCAP_SERVICES -


it seems watson user modeling service removed application. i'm getting following error in app.

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     @ object.watsonurl (/home/vcap/app/lib/config.js:33:53) 2015-04-09t15:23:38.44-0400 [app/0]   err     @ getpersonality (/home/vcap/app/lib/app.js:203:25) 2015-04-09t15:23:38.44-0400 [app/0]   err     @ async.waterfall.personalityuser1 (/home/vcap/app/lib/app.js:278:13) 2015-04-09t15:23:38.44-0400 [app/0]   err     @ fn (/home/vcap/app/node_modules/async/lib/async.js:641:34) 2015-04-09t15:23:38.44-0400 [app/0]   err     @ object._onimmediate (/home/vcap/app/node_modules/async/lib/async.js:557:34) 2015-04-09t15:23:38.44-0400 [app/0]   err     @ processimmediate [as _immediatecallback] (timers.js:345:15) 

what happened , need fix this?

the user modeling service renamed. personality insights. fixed adding new personality insights service app , updating code reading vcap_services.

instead of doing following:

var vcap_services = process.env["vcap_services"],     vcapservices;  if (vcap_services) {     vcapservices = json.parse(vcap_services); }  return vcapservices["user_modeling"][0].credentials.url; 

do following instead. note user_modeling related 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; 

additionally api changed bit... url url vcap_services + /v2/profile. vcap_services + /api/v2/profile

more vcapservices["personality_insights"][0].credentials.url + "/v2/profile".


Popular posts from this blog