0

I am using Node-RED and want to parse in Bluemix VCAP_SERVICES but I am getting an error. My code is:

var services = context.global.VCAP_SERVICES;
var env_cloudint = services['CloudIntegration'][0].credentials;

but I get this error :

TypeError: Cannot read property 'CloudIntegration' of undefined

I do have CloudIntegration in my VCAP_SERVICES. Do I need anything extra in my code to exploit VCAP_SERVICES?

1
  • 1
    Your error indicates that 'services' itself is undefined, not that the item 'CloudIntegration' in the 'services' array is undefined May 7, 2015 at 0:11

1 Answer 1

7

By default, environment variables are not added to the Function global context object. To access the Bluemix VCAP_SERVICES environment variable from a Node-RED flow, you will need to add it to the Function node's global context.

Edit bluemix-settings.js and add an entry to the functionGlobalContext property:

functionGlobalContext: { VCAP_SERVICES: JSON.parse(process.env.VCAP_SERVICES)}

Then redeploy your app. When redeployed, you can then access VCAP_SERVICES in a Function node as the context.global.VCAP_SERVICES variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.