Reputation: 1003
It is obvious that "result" is coming back as null from the query. If that is the case, why is it calling the "success" routine? I know that the course I am searching for does exist.
Any ideas?
var query = new Parse.Query("Courses");
var CourseObj = new Parse.Object("Courses");
query.equalTo("courseIdFromIOS", request.params.courseIdFromIOS);
query.first({
success: function (result) {
CourseObj = result;
response.success("course lookup good for: " + CourseObj.get("courseName"));
},
error: function () {
response.error("course lookup failed");
}
});
Upvotes: 1
Views: 445
Reputation: 435
A query always enters success loop if we are able to connect to Parse servers and searched through all the rows even if our query was unsuccessful since there is no error code corresponding to unsuccessful query .Once check this guide and also error codes section. https://www.parse.com/docs/js/guide#handling-errors
So in your case result is undefined
var query = new Parse.Query("MyClass");
var tmp = new Parse.Object("MyClass");
query.equalTo("username", "This does not exist in table");
query.first({
success: function (result) {
tmp = result;
alert("hii");
alert("course lookup good for: " + tmp.get("name"));
},
error: function () {
alert("helloooo");
}
});
Even in the above code it is entering success loop
Upvotes: 3