Auth0 Home Blog Docs

Using @auth0/auth0-spa-js outside of React Component

Hi There,

I’m using Auth-Spa-JS with React and using Auth0 sample like Hooks to handle authentication. I have setup an API with Auth0 and Node.js and it also setup according to example.

I need to use generateTokenSliently in my axios instance which is not a React component. For that as one of thread suggested in here I tried using the gist linked

But I’m getting error

Unhandled Rejection (Error): getAuth0Client Error
(anonymous function)
  21 |       client = await createAuth0Client(_initOptions);
  22 |       resolve(client);
  23 |     } catch (e) {
> 24 |       reject(new Error('getAuth0Client Error', e));
     | ^  25 |     }
  26 |   }
  27 | });