I am facing issue in reading credentials from a user-provided service that is binded to my application.
But it is giving error :
" 72 lua entry thread aborted: runtime error: ./common.lua:139: attempt to index field 'userProvidedServiceName' (a nil value)"
Below is the chunk of code which I have written in common.lua :
function get_app_configs_info()
local vcap_services = cjson.decode(os.getenv("VCAP_SERVICES"))
local vcapCredentials = vcap_services["*<myUserProvidedServiceName>*"][1].credentials;
return vcapCredentials
end
function M.get_app_configs()
return cjson.encode(get_app_configs_info())
end
@Greg Stroup , can you please suggest , as I saw in one of the questions in forum,that you were trying something similar with UAA .
Answer by Thuan Truong · Jun 09, 2017 at 09:34 AM
The user provided services appear in the VCAP_SERVICES like below, and you should change your code to:
local vcapCredentials = vcap_services["user-provided"][1].credentials;
and get property:
vcapCredentials.licenseKey
"user-provided": [ { "credentials": { "licenseKey": "xyzabcdxxxxxxx" }, "label": "user-provided", "name": "newrelic", "syslog_drain_url": "", "tags": [], "volume_mounts": [] } ]
@Thuan Truong I tried this way also,but still got the same error. Finally, I just returned vcap_services complete json from common.lua and parsed it in my .js file to get the credentials.
Setting up the Dashboard Seed project: bower error 4 Answers
"grunt serve" for Dashboard Seed App giving Errors- ServerResponse has no method 'Status' 4 Answers
Dashboard Seed Initial Requirements 3 Answers
Angular JS UI-Router resolve issue with predix - seed. 1 Answer
user login issue with predix seed 6 Answers