could not get response from express.js server using postman

Viewed 1569

when i make post request from postman, the request data was shown server but server response i.e status code and json object was not send to postman, postman was just loading... and after some time it says could not get response from the server.

here is my server.js class

var bodyParser = require('body-parser');
var express = require('express');

var {mongoose} = require('./db/mongoose');
var {Todo} = require('./models/todo');
var {Users} = require('./models/Users');

var app = express();
app.use(bodyParser.json());

app.post('/todos', (req, res) =>{
var todo = new Todo({
text: req.body.text
});

todo.save().then((doc) => {
res.send(doc);
}, (e) => {
res.status(400).send(e);
});

});

app.listen(3000, () =>{
console.log('started at port 3000');
});
1 Answers
Related