P
P
Pallid2015-05-28 14:23:38
JavaScript
Pallid, 2015-05-28 14:23:38

Why does a query sometimes not return a Result?

In the code below, sometimes no Result is returned, instead of this "500 (Internal Server Error)"
Client side:

//Событие во вьюхе
eventclicklike: function() {

     var self = this;
     var id = this.model.attributes.objectId;

       $.get('/checklike/'+id, 
            function(data) {
              console.log(data);
           }
      );  
     }

Server part:
app.get('/checklike/:id', function(req, res) {
      var user = Parse.User.current();
   
      var comm = new Comments();
      comm.id = req.params.id;
      var relationUser = user.relation("LikeCom");

      var query = relationUser.query();
      query.get(req.params.id).then (function(item) {
      var dvd = item;
      var w = dvd.get('likemy');
      var q = dvd.set('likemy',w-1);
      dvd.save();
      relationUser.remove(comm);
      user.save();
        res.json(dvd);
    }, function(error) {
        var query = new Parse.Query("Comments");
        query.get(req.params.id).then (function(item){
        relationUser.add(comm);
        user.save();
        var dvd = item;
        dvd.increment('likemy');
        dvd.save();
      }, function(error) {
          console.error("error: " + error.code + " " + error.message);
          res.error(error); 
      });
    });
  });

I can't figure out why this happens from time to time.
Although changes to the database occur anyway.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Deodatuss, 2015-05-28
@Deodatuss

why not look through the debugger why is this happening?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question