Why is res.json is not a function?

Hey guys, I’m trying to figure out how to login a user using bcyrpt.js and jwt but I keep getting

res.json is not a function

I think the issue is coming from server.js where I’m trying to use jwt after comparing passwords with bcrypt. Any suggestions? Thanks!

vuex store

  login({ commit }, user) {
      return new Promise((resolve, reject) => {
        commit('auth_request')
        axios({ url: 'http://localhost:3000/api/auth', data: user, method: 'POST' })
          .then(resp => {
            const token = resp.data.token
            axios.defaults.headers.common['Authorization'] = token
            commit('auth_success', token, user)
            resolve(resp)
          })
          .catch(err => {
            commit('auth_error')
            //localStorage.removeItem('token')
            reject(err)
            console.log("here" + err);
          })
      });
    },

auth.js

const express = require("express");
const authRouter = express.Router();
const passport = require("passport");


authRouter.post('/', passport.authenticate("local", {
    session: false
})
);

module.exports = authRouter;

server.js

passport.use(
    new LocalStrategy({
        usernameField: 'email',
        passReqToCallback: true,
    }, (req, username, password, done) => {
        User.findOne({ email: username }, (err, user) => {
            if (err) {
                console.log(err);
            }
            if (!user) {
                return done(null, false);
            }
            bcrypt.compare(password, user.password, (err, res) => {
                if (res) {
                    // passwords match! log user in
                    //done(null, user);
                    jwt.sign({ user }, process.env.secret, (er, token) => {
                        res.json({
                            token,
                            user
                        })
                    })
                    done(null, user);
                } else {
                    // passwords do not match!
                    return done(null, false);
                }
            });
        });
    })
);

This should help, check the parameters section:

Thanks I realized that I did not add “req” in my bcrypt compare. I am getting a 401 unauthorized error now. So I will make a new post for this error.