mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-06 01:15:28 +02:00
1.2 KiB
1.2 KiB
1. Install the SDK
npm install unleash-client
2. Run Unleash
const { initialize } = require('unleash-client');
const unleash = initialize({
url: '<YOUR_API_URL>',
appName: 'unleash-onboarding-node',
customHeaders: { Authorization: '<YOUR_API_TOKEN>' },
metricsInterval: 5000,
});
setInterval(() => {
console.log('Is enabled', unleash.isEnabled('<YOUR_FLAG>'));
}, 1000);
Production settings
In order to validate the connection, we changed some settings that you might want to revert. We recommend the following default settings.
const { initialize } = require('unleash-client');
const unleash = initialize({
url: '<YOUR_API_URL>',
appName: 'unleash-onboarding-node',
customHeaders: { Authorization: process.env.UNLEASH_API_KEY },
});
Additional resources
Now that we’ve validated the connection, you might want to look into more advanced use cases and examples: