I open the terminal and put the following commands
Sudo Mongode
/ Ex>which then outputs
[initandlisten] Waiting for connection to port 27017
I open another terminal and
Sado Mango
which opens the Mongo and prompts for the Mongo command, but when I go to the local host / 27017, I get the following message:
like this You are trying to reach MongoDB at the local driver port on HTTP.
I have created a simple node application while using Express and when I think
POST
data that the Mongodb is hung, this is the message that I get it in the terminal in which I start my express application and the page never posts the data. So I believe that the problem is within the mungo but I am not able to understand it.Posts / Info 200 120002ms
Here is my express code
var info = need ('../ Model / information '); Var path = requirement ('path'); Var FS = Requirement ('FS'); Var join = path.join; Export.form = function (req, res) {res.render ('info', {myName: 'Michael'}); }; Export.submit = function () {console.log ('export.submit within 1'); Return function (Rick, Race, Next) {console.log ('inside export.submit 2'); Var firstName = req.name.first; Var lastName = req.name.last; Info.create ({firstName: firstname, lastname: lastname}, function (mistake) {if (err) return next (err); res.redirect ('/')}; }};
model
var mongoose = is required ('mongoos'); Mongoose.connect ('MongoDB: // local host / information'); Var Schema = New Mongoose Sema ({first name: string, last name: string}); Module.exports = mongoose.model ('info', schema);
app.js
... app.get ('/ info', info.form); App.post ('/ info', info.submit); ...
You can start mongodb with
Mongode --httpinterface
and
http: // localhost: 28017
version Access 2.6: Mongodi by default disables HTTP interfaces.
View
No comments:
Post a Comment