[英]Parse.com Cloud Code error : TypeError: Cannot call method 'get' of undefined
It is obvious that "result" is coming back as null from the query. 很明显,“result”从查询中返回null。 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");
}
});
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. 如果我们能够连接到Parse服务器并搜索所有行,即使我们的查询不成功,查询也总是进入成功循环,因为没有与不成功查询相对应的错误代码。请查看本指南以及错误代码部分。 https://www.parse.com/docs/js/guide#handling-errors
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 即使在上面的代码中,它也进入了成功循环
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.