Home > Enterprise >  Why do I have a error when I use help me please keycloak.init?
Why do I have a error when I use help me please keycloak.init?

Time:05-21

how can I solve this problem? help me please keycloak.init({ onl oad: 'login-required' }).success(function () {}

TypeError: keycloak.init is not a function

CodePudding user response:

Instead of :

const keycloak = Keycloak('./public/keycloak.json');

Try this:

const keycloak = Keycloak('/keycloak.json');

and set promiseType to native in the init options like this(in your case) :

keycloak.init({onLoad: 'login-required', promiseType: 'native'}).then(authenticated => {
   this.setState({ keycloak: keycloak, authenticated: authenticated })
 })

Share E

CodePudding user response:

instead of :

const keycloak = Keycloak('./public/keycloak.json');

Try this:

const keycloak = Keycloak('/keycloak.json');

and set promiseType to native in the init options like this(in your case) :

keycloak.init({onLoad: 'login-required', promiseType: 'native'})
.then(authenticated => { this.setState({ keycloak: keycloak, authenticated: authenticated }) })
  • Related