Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken code samples #348

Merged
merged 6 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion website/docs/advanced/targeting.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const userObject = {
email: userEmail,
custom: { domain: userDomain },
};
const value = configCatClient.getValue(key, defaultValue, callback, userObject);
const value = await configCatClient.getValueAsync(key, defaultValue, userObject);
```

Support for confidential comparators was introduced in these SDK versions:
Expand Down
32 changes: 21 additions & 11 deletions website/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ then you can **connect your application** to the ConfigCat service to access you

### Connect your application

There are ready to use code snippets for `.NET`, `Java`, `Android (Java)`, `Kotlin`, `iOS`, `Dart (Flutter)`, `Node`, `JavaScript`, `Python`, `Go`, `PHP`, `Elixir`, `C++` on the <a href="https://app.configcat.com" target="_blank">ConfigCat Dashboard</a>, just scroll down to the **SDK Key and steps to connect your application** section.
There are ready to use code snippets for `.NET`, `Java`, `Android (Java)`, `Kotlin`, `iOS (Swift)`, `Dart (Flutter)`, `Node`, `JavaScript`, `React`, `Python`, `Go`, `PHP`, `Ruby`, `Elixir`, `C++` on the <a href="https://app.configcat.com" target="_blank">ConfigCat Dashboard</a>, just scroll down to the **SDK Key and steps to connect your application** section.

All the ConfigCat SDKs are open-source and available on <a href="https://github.com/configcat" target="_blank">GitHub</a>.

Expand All @@ -33,14 +33,24 @@ See the detailed [Docs on how to use the ConfigCat SDKs.](/sdk-reference/overvie
Here's a short example to demonstrate the concept:

```js
var configcat = require('configcat-client');
var client = configcat.createClient('YOUR SDK KEY HERE');

client.getValue('isMyFeatureEnabled', false, (value) => {
if (value === true) {
do_the_new_thing();
} else {
do_the_old_thing();
}
});
// 0. If necessary, install the ConfigCat SDK package for the platform you use.
// E.g. `npm install configcat-js`

// 1. Import the ConfigCat SDK package.
import * as configcat from 'configcat-js';
// (Or use `const configcat = import("https://esm.sh/configcat-js");` instead
// if you just want to do a quick test in a scratchpad.)

// 2. Get a client object for the SDK Key of your config.
const client = configcat.getClient('YOUR SDK KEY HERE');

// 3. Evaluate a feature flag using the client object.
const value = await client.getValueAsync('isMyFeatureEnabled', false);

// 4. Based on the value of the feature flag decide whether or not to enable the related feature.
if (value) {
do_the_new_thing();
} else {
do_the_old_thing();
}
```