Skip to content

Commit 0222412

Browse files
update
1 parent 7705336 commit 0222412

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

articles/azure-app-configuration/howto-variant-feature-flags-javascript.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ In this tutorial, you use a variant feature flag to manage experiences for diffe
7676
// Serve static index.html from the current folder
7777
server.use(express.static("."));
7878
79+
// This API returns the different greeting messages based on the segment the user belongs to.
80+
// It evaluates a variant feature flag based on user context. The greeting message is retrieved from the variant configuration.
7981
server.get("/api/getGreetingMessage", async (req, res) => {
8082
const { userId, groups } = req.query;
8183
const variant = await featureManager.getVariant("Greeting", { userId: userId, groups: groups ? groups.split(",") : [] });
@@ -157,6 +159,7 @@ In this tutorial, you use a variant feature flag to manage experiences for diffe
157159
</div>
158160
159161
<script>
162+
// extract URL parameters to simulate user login
160163
document.addEventListener('DOMContentLoaded', function() {
161164
const urlParams = new URLSearchParams(window.location.search);
162165
const currentUser = urlParams.get('userId') || '';
@@ -176,7 +179,7 @@ In this tutorial, you use a variant feature flag to manage experiences for diffe
176179
method: "GET"
177180
});
178181
const result = await response.json();
179-
greetingElement.textContent = result.message || "Quote of the Day";
182+
greetingElement.textContent = result.message || "";
180183
quoteContent.style.display = 'block';
181184
loadingElement.style.display = 'none';
182185
}
@@ -200,6 +203,8 @@ In this tutorial, you use a variant feature flag to manage experiences for diffe
200203
</html>
201204
```
202205
206+
For simplicity, the example extracts the `userId` from URL query parameters (e.g., `?userId=UserA`) to simulate different user identities.
207+
203208
## Run the application
204209
205210
1. Set the environment variable named **AZURE_APPCONFIG_ENDPOINT** to the endpoint of your App Configuration store found under the *Overview* of your store in the Azure portal.
@@ -228,7 +233,7 @@ In this tutorial, you use a variant feature flag to manage experiences for diffe
228233
node server.js
229234
```
230235
231-
1. Open your browser and visit `localhost:8080` to see the app running. You should see the default greeting message.
236+
1. Open your browser and navigate to `localhost:8080`. You should see the default view of the app that doesn't have any greeting message.
232237
233238
:::image type="content" source="media/howto-variant-feature-flags-javascript/default-variant.png" alt-text="Screenshot of the Quote of the day app, showing no greeting message for the user.":::
234239
23.6 KB
Loading
32.9 KB
Loading
28.6 KB
Loading

0 commit comments

Comments
 (0)