I'm attempting to follow a tutorial with what appears to be the exact same code for the Auth0 component that will be calling Auth0 to do authorization.
'''
import auth0 from "auth0-js";
function Auth () {
auth0 = new auth0.WebAuth({
domain: process.env.DOMAIN,
clientId: process.env.CLIENT_ID,
redirectUri: "http://localhost:3000/callback",
audience: "dev-pe-mju0a.us.auth0.com/userinfo",
responseType: "token id_token",
scope: "openid"
})
constructor() {
this.login = this.login.bind(this);
}
login() {
this.auth0.authorize();
}
}
export default Auth;
'''
I can't seem to get past the compiler. Giving me parsing error at the constructor () {
Apologies if this is a stupid question, but I'm new to programming and I've exhausted my capabilities!
Looks like you want this to be a class instead of a function. You cannot put a property on a function (constructor() and login()) like that.
class Auth {
...
}