I keep getting a SyntaxError: Unexpected token )'
error for the following code:
passport.use(
'local-signup',
new LocalStrategy({
usernameField: 'email',
passwordField: 'password',
passReqToCallback: true, // pass back req to callback
},
(req, email, password, done) => {
// ...
},
),
);
It really only started after I put arrow functions in. I think I'm missing something syntax-wise. I'm using the airbnb style guide & linter btw. Running Node.js LTS. VS Code doesn't give any parsing errors either in the editor itself. The code works when transpiled to ES2015 via Babel. I'm still curious why it isn't working with the ES6 syntax.
The problem is that in two places you're using a trailing comma in function syntax, i.e. a comma after the last argument of a function.
passport.use(
'local-signup',
new LocalStrategy({
usernameField: 'email',
passwordField: 'password',
passReqToCallback: true, // pass back req to callback
},
(req, email, password, done) => {
// ...
},
// ^
),
// ^
);
This syntax is part of ECMAScript 2017, and is not supported by Node.js before version 8.0.0, but can be transpiled using Babel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With