Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strongloop - Get config values from remote methods or model hooks

Tags:

strongloop

I have a node.js project using StrongLoop with config.local.json and config.json files containing config key value pairs. In server.js I used the following code to retrieve values for keys:

var loopback = require('loopback');
var app = module.exports = loopback();
var value = app.get('key');

However, in Model remote methods or model hooks, how can I retrieve these config key values there?

like image 862
marsairic Avatar asked Apr 01 '26 20:04

marsairic


1 Answers

The answer is get the already created Loopback application, which has access to the config file, and has loaded it.

var app = require('server.js');
var value = app.get('key');
like image 160
marsairic Avatar answered May 05 '26 11:05

marsairic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!