1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

feat(onboarding): nodejs snippet for production (#8256)

This commit is contained in:
Tymoteusz Czech 2024-09-25 15:45:53 +02:00 committed by GitHub
parent 44bf6615a3
commit c7427f4b91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View File

@ -141,6 +141,8 @@ export const TestSdkConnection: FC<ITestSdkConnectionProps> = ({
.replace('<YOUR_API_TOKEN>', apiKey)
.replace('<YOUR_API_URL>', apiUrl)
.replaceAll('<YOUR_FLAG>', feature);
const [connectSnippet, _productionSnippet, _otherResourcesSnippet] =
snippet.split('---\n');
return (
<SpacedContainer>
@ -164,7 +166,7 @@ export const TestSdkConnection: FC<ITestSdkConnectionProps> = ({
</ChangeSdk>
<SectionHeader>Setup the SDK</SectionHeader>
<Markdown components={{ code: CodeRenderer }}>
{snippet}
{connectSnippet}
</Markdown>
</Box>
</SpacedContainer>

View File

@ -21,3 +21,21 @@ setInterval(() => {
console.log('Is enabled', unleash.isEnabled('<YOUR_FLAG>'));
}, 1000);
```
---
```js
const { UnleashClient } = require('unleash-proxy-client');
const unleash = new UnleashClient({
url: '<YOUR_API_URL>',
appName: 'unleash-onboarding-node',
customHeaders: { Authorization: process.env.UNLEASH_API_KEY },
});
unleash.start();
```
---
- [SDK repository with documentation](https://github.com/Unleash/unleash-client-node)
- [Node.js SDK example with CodeSandbox](https://github.com/Unleash/unleash-sdk-examples/tree/main/JavaScript)
- [Node.js SDK tutorial](https://dev.to/reeshee/how-to-implement-feature-flags-in-nodejs-using-unleash-3907)