I am trying to save a user to mongodb database using post request as follow, but I got the error TypeError: User is not a function. It\'s a pretty simple set up
TypeError: User is not a function.
I was also facing the same error but this worked for me.
I did change my export file
var User = mongoose.model('User',userSchema); module.exports = {User};
To
module.exports = mongoose.model('User', userSchema);