NodeJS Overview

The client has the following attributes:

View featureflagtech-node on npm.

Step 1: Install Client

Install the client into your application via npm:

  npm install featureflagtech-node --save

Step 2: Import package

Now require in the client and instantiate it.

  const FeatureFlagTechClient = require( "featureflagtech-node" );  

Step 3: Create the client with your API Key

You also need to use your API key...

  const f2t = new FeatureFlagTechClient({

As this requires a HTTP request you will need to call getSourceFile before the client is ready:

  await f2t.getFlag();

Step 4: Get your flag value

You can interrogate the client for flag values in two ways.

Technique 1

You can get a flag value:

  f2t.get( "yourFlagName" );

This can be used as a condition in if statements.

  if ( f2t.get( "yourFlagName" ) ) {
    // application code to show the feature
  else {
    // the code to run if the feature is off

Technique 2

Or you can use the library's pattern instead. Here's an example:

  f2t.when( "yourFlagName" )
    .is( true, () => {
      // application code to show the feature
    .else( () => {
      // the code to run if the feature is off

More Details

Need more information? See more techniques below.