Issue using "require" in bluemix function nodes

Hi, I have followed a couple of tutorials to add a require in bluemix function node, in particular: https://nodered.org/docs/writing-functions.html

In my case, I need to have not just a require but also with parameters (?) :
var ovh = require('ovh')({
appKey: 'your_app_key',
appSecret: 'your_app_secret',
consumerKey: 'your_consumer_key'
});

This works perfectly fine on a local instance of node.js....

With bluemix, I have added in bluemixsettings:
functionGlobalContext: {
ovh:require('ovh')({
endpoint: 'ovh-eu',
appKey: 'key',
appSecret: 'key',
consumerKey: 'key'
})
},

and in my function node I call:
var ovh = global.get('ovh');
ovh.request('GET', '/sms', function (err, serviceName) (... etc etc )

when injecting, the node says: "TypeError: Cannot read property 'request' of undefined"
So ovh doesn't get defined properly, I guess.
I have tried to put the variables in the function node instead of bluemixsettings, with no more success. "ovh is not a function"

Can anyone help? Thanks in advance.

Did this ever get solved?
I am still seeing similar.

Hi,

Yes. In my case, it was a beginners issue. I THOUGHT I was modifying bluemixsettings with the above code.
I was not actually. Misuse of the bluemix provided code editor.
Once I updated the code correctly, it worked.

1 Like