https://www.growthbook.io/ logo
#ask-questions
Title
# ask-questions
b

bland-soccer-81127

10/19/2022, 2:32 PM
Hi, I am starting with growthbook and have created a feature, but when I log the JSON from growthbook.evalFeature("feature_id") on the browser console it always returns that it is off. I am not Self Hosting. Does anyone have an idea of what can be missing?
f

future-teacher-7046

10/19/2022, 2:34 PM
Can you log
growthbook.getFeatures()
? That should return all of the features loaded into the SDK
b

bland-soccer-81127

10/19/2022, 2:37 PM
It is empty this object
But I can log the features I have for my environment
f

future-teacher-7046

10/19/2022, 2:41 PM
Hmm. So it's setting the features correctly at first, but when you later do
getFeatures()
it returns an empty object? Is there anywhere else in your code that is calling
setFeatures()
? Are you sure it's the exact same instance of GrowthBook and you aren't creating multiple ones?
b

busy-horse-73824

10/19/2022, 2:42 PM
maybe an obvious one, but just in case - you mentioned logging:
growthbook.evalFeature("feature_id")
But your feature is
hide-element
, not
feature_id
Or were you actually logging:
growthbook.evalFeature("hide-element")
b

bland-soccer-81127

10/19/2022, 2:52 PM
The feature_id was an example, but thanks anyway!
@future-teacher-7046 Exactly, when I do
getFeatures()
returns an empty object. I'm calling the
setFeatures()
only once
Can it be any other configuration in the app?
f

future-teacher-7046

10/19/2022, 2:56 PM
You are calling
setFeatures()
inside of an async callback. Is it possible when you log
getFeatures()
it's before the fetch is done?
b

bland-soccer-81127

10/19/2022, 3:04 PM
Yes, it seams that it is happening
9 Views