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

creamy-rocket-65969

11/06/2022, 12:58 AM
growthbook.isOn()
never returns true on the Javascript sdk. What am I doing wrong?
Hi, I’m just getting started with GrowthBook on a side project using plain javascript. Copied the installation and quick usage starter code from the docs into my html page. I see the flag enabled on https://cdn.growthbook.io/api/features/prod_cbAOvmDygOHhAGOsaKdMhs7lI3wfI9bNAIqIeyNhos
Copy code
{
  "status": 200,
  "features": {
    "alas": {
      "defaultValue": true
    },
    "bar": {
      "defaultValue": "foo"
    },
    "lorem": {
      "defaultValue": true
    }
  },
  "dateUpdated": "2022-11-06T00:34:37.739Z"
}
In browser console, I’m not seeing
lorem
enabled:
Copy code
if (growthbook.isOn("lorem")) {
            console.log("Lorem is on")
        } else {
            console.log("Lorem is off")
        }
Lorem is off
gb.html
f

future-teacher-7046

11/06/2022, 9:28 PM
Hi, in your code, you are calling
setFeatures
asynchronously, so it's not available immediately. If you wait until after that to call
growthbook.isOn
it should work.
c

creamy-rocket-65969

11/07/2022, 3:27 PM
hi @future-teacher-7046 thanks for replying! I tried to wrap the `growthbook.isOn` call in async/await however it didn’t seem to work either. is there a reference implementation I can follow?
67 Views