gpt4 book ai didi

javascript - 解析云代码查询不断出现未定义

转载 作者:行者123 更新时间:2023-11-30 12:08:38 25 4
gpt4 key购买 nike

我是一个快速的初学者开发者,对 javascript 没有真正的经验。在过去的几个小时里,我一直在尝试使这个简单的查询正常工作,但无法弄清楚哪里出了问题。

我想获取名为“Post”的表中一行的“installationId”属性。所选行必须匹配特定的“id”。

我已经尝试了很多 var a 和 var b 的变体。像 results.get["installationId"] 或将查询更改为 find() 并执行 results[0].get["installationId"]。等等

这是我的代码,下面是我在 Parse Cloud 上记录的错误。

var postId = request.object.get('postId'); console.log("文章编号为"+ 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)

最佳答案

像下面这样尝试。可能会有所帮助。

results[0].get("installationId")

var postObj = results[0].toJSON();
var subject = postObj.installationId;

关于javascript - 解析云代码查询不断出现未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34469824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com