I am trying to make login in Node.js. but i am confused how to use database.And my Login.html & database.js is like. http://scotch.io/tutorials/javascript/easy-node-authentication-setup-and-local So please give me proper idea.
<form action="/login" method="post">
<div class="form-group">
<label>Email</label>
<input type="text" class="form-control" name="email">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" class="form-control" name="password">
</div>
<button type="submit" class="btn btn-warning btn-lg">Login</button>
database.js:
module.exports = {
'url' : 'your-database-here'
};
In your server.js should be this bit of code (assuming you are following the tutorial you linked exactly).
var configDB = require('./config/database.js');
mongoose.connect(configDB.url);
According to that code, your database.js file must be in a config folder (rather then in the same folder as server.js). So make sure you are doing that.
Next, place your mongodb url like so in your database.js.
module.exports = {
'url' : 'mongodb://<user>:<pass>@mongo.onmodulus.net:27017/Mikha4ot'
};
Make sure to replace <user> with your username and <pass> with your password.
I will help you.


module.exports

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With