# ask-questions


03/27/2024, 11:01 PM
I'm having an issue getting the SDK set up in a Nest JS environment, but really all I'm trying to do is create a class that contains the configuration for growthbook and provides some wrapping functions. No errors are being thrown when initializing growthbook, but it always returns the default value passed to
- anyone else experienced this?
Here's the code:
Copy code
import {PatientAppUserInfo} from '@ciitizen/back-end-apps-patient-app-nestjs'
import {extractEmailDomain} from '@ciitizen/common-utils'
import {Experiment, GrowthBook, Result} from '@growthbook/growthbook'
import {Injectable} from '@nestjs/common'

type FeatureFlagKey = 'test-2'

const gb = new GrowthBook({
  apiHost: '<>',
  clientKey: '<redacted>',
  enableDevMode: true,
  subscribeToChanges: false,
  trackingCallback: (experiment: Experiment<any>, result: Result<any>): void => {
    // TODO: Make amplitude available on the backend to send events

export class ExperimentationService {
  private _growthbook: GrowthBook

  constructor() {
    this._growthbook = gb

  async getCohort({user, featureFlagKey}: {user: PatientAppUserInfo; featureFlagKey: FeatureFlagKey}): Promise<string> {
    await this._growthbook.loadFeatures()

    await this._growthbook.setAttributes({
      emailDomain: extractEmailDomain(,
      id: user?.authTokenInfo.auth0UserId,

    const defaultValue = 'not enabled'
    let result = defaultValue
    // while (result === defaultValue) {
    result = this._growthbook.getFeatureValue(featureFlagKey, defaultValue)
    // }
    return result


03/28/2024, 4:27 AM
that looks okay
can you do some more debugging? Is it making the network request? do the features load?


03/28/2024, 4:16 PM
No, it is not making the network requests. The features do not load. I created a dummy next JS project to validate that the package works in a blank server context and the features were retrieved successfully, which leads me to be there is something about the NestJS environment which is preventing requests from being made.