Answer the question
In order to leave comments, you need to log in
What's wrong with saving?
Good afternoon.
I save to the database (in mongo)
function addProducts(name) {
var data = {
name: name
};
return $http.post('/products/add', data)
.then(addProductsComplete)
.catch(addProductsFailed);
function addProductsComplete(response) {
console.log('Сохранено');
return response.data;
}
function addProductsFailed(error) {
console.log('error in POST Products service ');
}
}
router.post('/add', function (req, res) {
var product = new Products({
name: req.body.name
});
product.save(function (err) {
if (err)
throw err;
});
});
error in POST Products service
console.log('Сохранено');
but it is not caused. Answer the question
In order to leave comments, you need to log in
So you don’t send a response, add res.sendStatus(200)
Otherwise, it gives you an error by timeout
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question