我是一个快速入门的开发人员,不太熟悉javascript。在过去的几个小时里,我一直试图使这个简单的查询正常工作,却找不出出了什么问题。
我想在一个名为"Post“的表中获取行的"installationId”属性。选中的行必须匹配特定的"id“。
我尝试过许多变量,比如var a和var b,比如results.get["installationId"],或者将查询更改为find()并执行results[0].get["installationId"]。等。
这是我的代码,下面是我在Parse上记录的错误。
var postId = request.object.get('postId');console.log("post id is "+ postId)
query = new Parse.Query("Post");
query.equalTo("postId", postId);
query.first({
success: function(results) {
// results is an array of Parse.Object.
var a = results //.get["installationId"]
console.log("a query success from cloud code "+a)
var b = results.object.get["installationId"]
console.log("b query success from cloud code "+b)
},
error: function(error) {
// error is an instance of Parse.Error.
console.log("query error from cloud code")
}
});下面是日志中返回的内容:
I2015-12-26T08:01:26.373Z] - a query success from cloud code undefined
I2015-12-26T08:01:24.915Z] - post id is 1000
E2015-12-26T08:01:24.881Z] - v12 after_save triggered for AddVote:
Input: {"object":{"UDID":"[confedential]","createdAt":"2015-12-26T08:01:24.876Z","objectId":"[confedential]","postId":"1000","updatedAt":"2015-12-26T08:01:24.876Z","userId":[confedential]}}
Result: TypeError: Cannot read property 'get' of undefined
at e.query.first.success (main.js:26:56)
at e.<anonymous> (Parse.js:14:28823)
at e.i (Parse.js:14:27528)
at e.a.value (Parse.js:14:26888)
at e.i (Parse.js:14:27655)
at e.a.value (Parse.js:14:26888)
at e.i (Parse.js:14:27655)
at e.a.value (Parse.js:14:26888)
at e.<anonymous> (Parse.js:14:27599)
at e.i (Parse.js:14:27528)发布于 2015-12-26 12:41:57
试试下面的样子。也许能帮上忙。
results[0].get("installationId")或
var postObj = results[0].toJSON();
var subject = postObj.installationId;https://stackoverflow.com/questions/34469824
复制相似问题