Setup the SDK
npm install --save @nonfig/node-sdk
yarn add @nonfig/node-sdk
Initialize SDK
const { nonfig } = require('@nonfig/node-sdk')
import {nonfig} from '@nonfig/node-sdk'
const nonfigClient = nonfig({
appKey: '__appKey__',
appSecret: '__apiSecret__',
debug: true,
cacheEnable: true,
cacheTtl: 60,
})
Retrieve single configuration
const promotion = await nonfigClient.findByName('/path/to/promotion')
const config = promotion.data
if (!config.enabled) {
hidePromotionBanner()
}
Retrive multiple configurations
Search by Path
const settings = await nonfigClient.findByPath({path: '/settings/*'})
for (const config of settings) {
}
Searh by Label(s)
const settings = await nonfigClient.findByLabels(['user:eu', 'plan:enterprise'])
for (const config of settings) {
}
Searh by List of ID
const settings = await nonfigClient.findById(id)
if (!settings.enabled) {
hidePromotionBanner()
}
Last updated on 10/14/2020