Answer the question
In order to leave comments, you need to log in
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);
}
);
}
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);
});
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question