![]() |
%!s(int64=5) %!d(string=hai) anos | |
---|---|---|
dist | %!s(int64=5) %!d(string=hai) anos | |
example | %!s(int64=5) %!d(string=hai) anos | |
.gitignore | %!s(int64=5) %!d(string=hai) anos | |
.npmignore | %!s(int64=5) %!d(string=hai) anos | |
.snyk | %!s(int64=5) %!d(string=hai) anos | |
README.md | %!s(int64=5) %!d(string=hai) anos | |
lofig.js | %!s(int64=5) %!d(string=hai) anos | |
package-lock.json | %!s(int64=5) %!d(string=hai) anos | |
package.json | %!s(int64=5) %!d(string=hai) anos | |
webpack.config.js | %!s(int64=5) %!d(string=hai) anos |
npmjs.com/package/config for client side JavaScript
npm install lofig --save --production
You can also use https://unpkg.com/lofig@latest/dist/lofig.min.js.
import 'lofig' from 'lofig'; // not necessary if using CDN Link
// change config folder
lofig.folder = 'config/default.json';
// check if property exists
await lofig.has('secret');
// OR
lofig.has('secret').then(res => {
if (res) console.log("secret is defined!");
})
// return property
await lofig.get('secret');
// OR
lofig.get('secret').then(secret => {
if (secret) console.log("secret:", secret);
})
See example folder for more details.