javascript - $http PUT request is slow and unsuccesful no status code, no errors -


when user submits form, server should receive put request updates poll database. what's odd in dev console, can see callback poll.update called immediately, put request takes 120000 ms. , though dev console shows successful put request, database isn't updated, , .success callback never called.

updated [object object]

put /api/polls/5599725069753a7711fd4274/0 200 120083ms

in browser see put request without status code. don't see error messages.

the routes poll controller:

 var express = require('express');  var controller = require('./poll.controller');  var router = express.router();   router.put('/:id', controller.update);   module.exports = router; 

the mongoose poll controller:

exports.update = function(req, res) {    var update = {$set: {'poll_name': 'poll has been updated'}};    poll.update(req.params.id, update, function(err, num, doc) {   if(err) console.log(err);   else {     console.log('updated ' + doc); // logged after vote submitted     } }); }; 

angular code that's called when submit clicked:

$scope.addvote = function() {   $http.put('api/polls/' + $scope._id).success(function(result) {       console.log('vote submitted'); //this never called     }   ); }; 

your server isn't sending response , that's reason why see request ending after long time. add res.send after console.log , see response received on client side


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -