× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

500 internal server error while saving data to mongoDB

Jul 21, 2015
<p>try</p> <pre><code>var newUser = new User({ email: user.email, password: user.password }) </code></pre> <p>instead of</p> <pre><code>var newUser = new({ email: user.email, password: user.password }) </code></pre> <p>and ensure User has a schema set like </p> <pre><code>var UserSchema = new Schema({ email : String, password: String, }); module.exports = mongoose.model('User',UserSchema); </code></pre> <p>I assume this is in a different file, and import user schema</p> <pre><code>var User = require(location of file); </code></pre> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/28833201/500%20internal%20server%20error%20while%20saving%20data%20to%20mongoDB/28833309">Stack Overflow</a>.</p>
comments powered by Disqus