Javascript Parse.com无法读取属性';objectId';未定义的
在使用Javascript Parse.com无法读取属性';objectId';未定义的,javascript,parse-platform,Javascript,Parse Platform,在使用Parse.Query接收对象时,我遇到了一个奇怪的错误: var installationQuery = new Parse.Query(Parse.Installation); installationQuery.each(function(installation) { console.log(JSON.stringify(installation)); console.log(installation.objectId); console.log(insta
Parse.Query
接收对象时,我遇到了一个奇怪的错误:
var installationQuery = new Parse.Query(Parse.Installation);
installationQuery.each(function(installation) {
console.log(JSON.stringify(installation));
console.log(installation.objectId);
console.log(installation.get("objectId"));
}
第一个日志显示我收到了一个非常正常的安装
对象:
{"appIdentifier":"XXX","appName":"XXX",...,"objectId":"XXXXXXXXXX"}
但另外两个给了我这个错误:
Result: TypeError: Cannot read property 'objectId' of undefined
如何提取
installation
对象的objectId
。可以通过对象的id
字段访问objectId
,这有点违反直觉,但应该可以工作。以及console.log(installation)的输出是什么代码>?比约恩已经提出了一个可行的解决方案。因为从我的第一个控制台日志中可以清楚地看到,有一个健康的对象包含我需要的内容,所以访问它只是一个问题。请使用for循环for(var key in installation)console.log(key)代码>我知道这必须是一个简单的解决方案:)