我正在学习javascript,我想写一个简单的Parse CloudCode脚本。不幸的是我收到了下面发布的错误,这似乎很常见,不幸的是,我在这方面缺乏技能,即使有了可用的资源,我也无法解决问题。
非常感谢任何解决方案,教程或解释。
错误(由iOS应用程序记录):
error calling 'updateLastSeen' function: Error Domain=Parse Code=141 "TypeError: Cannot call method 'slice' of undefined
at e.query.first.success (main.js:11:58)
at e.<anonymous> (Parse.js:14:28998)
at e.i (Parse.js:14:27703)
at e.a.value (Parse.js:14:27063)
at e.i (Parse.js:14:27830)
at e.a.value (Parse.js:14:27063)
at e.i (Parse.js:14:27830)
at e.a.value (Parse.js:14:27063)
at e.<anonymous> (Parse.js:14:27774)
at e.i (Parse.js:14:27703)" UserInfo={code=141, temporary=0, error=TypeError: Cannot call method 'slice' of undefined
at e.query.first.success (main.js:11:58)
at e.<anonymous> (Parse.js:14:28998)
at e.i (Parse.js:14:27703)
at e.a.value (Parse.js:14:27063)
at e.i (Parse.js:14:27830)
at e.a.value (Parse.js:14:27063)
at e.i (Parse.js:14:27830)
at e.a.value (Parse.js:14:27063)
at e.<anonymous> (Parse.js:14:27774)
at e.i (Parse.js:14:27703), NSLocalizedDescription=TypeError: Cannot call method 'slice' of undefined
at e.query.first.success (main.js:11:58)
at e.<anonymous> (Parse.js:14:28998)
at e.i (Parse.js:14:27703)
at e.a.value (Parse.js:14:27063)
at e.i (Parse.js:14:27830)
at e.a.value (Parse.js:14:27063)
at e.i (Parse.js:14:27830)
at e.a.value (Parse.js:14:27063)
at e.<anonymous> (Parse.js:14:27774)
at e.i (Parse.js:14:27703)}
Main.js CloudCode脚本(相关部分):
var query = new Parse.Query(Parse.User);
query.equalTo('email', request.params.email);
query.first({
success: function(user) {
var mutableLastSeenDictionariesArray = user.lastSeen.slice(0);
for (var i = 0; i < mutableLastSeenDictionariesArray.length; i++) {
var lastSeen = mutableLastSeenDictionariesArray[i];
if (lastSeen[response.params.email]) {
i = mutableLastSeenDictionariesArray.length+1;
mutableLastSeenDictionariesArray.splice(i, 1, request.params["builtDictionary"]);
user.lastSeens = mutableLastSeenDictionariesArray;
user.save;
}
}
},
error: function(error) {
response.error(error.code, "Error: " + error.message);
}
});
谢谢。
答案 0 :(得分:0)
所以问题是.lastSeens属性是一个数组是空的,因此是未定义的(null)。
解决方案是实施支票?=vLogs(i)="P:\test2.txt"
?=sFile="P:\test2.txt"
并相应处理。
感谢@danh指出我正确的方向。