I’m trying to register an user and I use a constructor class for it, but when I put the parameters in the constructor and make the query, it takes the first parameter that I passed to the constructor and puts all the information as if it were an object of that parameter. Like this:
enter image description here
And when I try to put a parameter to be able to use it like this this.username = username, I meet with this
Here’s my code:
class User{
constructor(user){
this.username = user.username
this.email = user.email
this.birthday = user.birthday
this.picture = user.picture
this.password = user.password
}
}
//////
async signUp(req,res){
const newUser = new User(req.body)
console.log(newUser)
const result = await newUser.save()
console.log(result)
return res.redirect("/")
}
////
router.post("/signup", authcontroller.signUp)