[MissingUsernameError]: No username was given

23 views Asked by At

I am getting this error while using passport-local-mongoose package. Using postman does not give error but using frontend connected it gives that no username was given error.

user.js:

const mongoose = require("mongoose");
const passportLocalMongoose = require("passport-local-mongoose");
const findOrCreate = require("mongoose-findorcreate");

const userSchema = new mongoose.Schema({
    firstName: String,
    lastName: String,
    username: String,
    password: String,
    googleId: String
});

// userSchema.plugin(passportLocalMongoose, { usernameField: "email" });
userSchema.plugin(passportLocalMongoose);

userSchema.plugin(findOrCreate);

const User = mongoose.model("User", userSchema);

module.exports = User;

Missing username error is coming.

0

There are 0 answers