0
語境Parse.com Cloud代碼afterSave()錯誤:「Uncaught嘗試使用指向新的未保存對象的指針保存對象。」
我使用Parse.com我的後端的web應用程序之後。我遇到的問題涉及Cloud代碼。
在用戶完成他們的個人資料,我想打電話給一個afterSave()函數更新數據集中MY_TABLE幾個領域。
正在更新的字段(variable01,variable02和variable03)通過輸入參數param01和param02的函數MY_FUNCTION檢索。
錯誤
我碰到下面的錯誤,我無法修復:「未捕獲試圖挽救的對象的指針到一個新的,未保存的對象」
代碼
Parse.Cloud.afterSave("PROFILE_COMPLETE", function(request) {
// Use Master Key
Parse.Cloud.useMasterKey();
// Identify Parameters in Request
var param01 = request.user.get('param01');
var param02 = request.user.get('param02');
// Print Parameters to Console
console.log("Parameter 01 (" + param01 + ") successfully identified");
console.log("Parameter 02 (" + param02 + ") successfully identified");
// Identify Variables by Calling MY_FUNCTION()
Parse.Cloud.run('MY_FUNCTION', {param01: param01, param02: param02}, {
success: function(results) {
// Print Results
console.log("Function MY_FUNCTION() returned successful response");
console.log(results);
// Print Result Variables
console.log("Identified variable01 = " + results.variable01);
console.log("Identified variable02 = " + results.variable02);
console.log("Identified variable03 = " + results.variable03);
// Do I need to extend MY_TABLE or something else here???
// I am doing the update and save wrong...
// Update 'Complete' Data
request.object.set("variable01", results.variable01);
request.object.set("variable02", results.variable02);
request.object.set("variable03", results.variable03);
// Save Variables to 'MY_TABLE'
request.object.save(null, {
success: function(results) {
console.log("Variables successfully updated in MY_TABLE dataset");
console.log(results);
},
error: function(error) {
console.log("Error when saving variables in MY_TABLE dataset");
console.log("Error " + error.code + ": " + error.message);
}
})
},
error: function(error) {
console.log("There was an error when running function MY_FUNCTION()");
console.log(error);
}
});
});
也許不是'request.object.save',只是'響應.success'。 – eth3lbert
** Parse.Cloud.afterSave()**沒有作爲函數語法的一部分調用的「響應」:https://parse.com/docs/cloud_code_guide#functions-aftersave – Jesse
哦,你說得對。 – eth3lbert