我正在使用新的开源解析服务器,这就是我在main.js
中创建对象所拥有的。
Parse.Cloud.define("purchaseItem", function(request, response) {
Parse.Cloud.useMasterKey();
var order, custom;
Parse.Promise.as().then(function() {
var fullreceipt;
var receiptData = new Array();
receiptData = request.params.receipt.titles;
if(receiptData){
console.log('value of recept data is good');
}
if (!receiptData){
console.log('Value of receiptData is empty');
}
for (var i = 0; i < receiptData.length; i++) {
console.log(receiptData[i]);
fullreceipt = receiptData[i];
console.log(fullreceipt);
//Do something
}
var currentUser = Parse.User.current();
order = new Parse.Object('Order');
order.set('name', request.params.name);
order.set('email', request.params.email);
order.set('address', request.params.address);
order.set('zip', request.params.zip);
order.set('city_state', request.params.city_state);
order.set('fulfilled', false);
order.set('charged', false); // set to false until we actually charge the card
order.set('user', currentUser);
order.set('receipt', request.params.receipt);
order.set('tipAmount', request.params.tipAmount);
order.set('taxAmount', request.params.taxAmount);
order.set('orderInstructions', request.params.instructions);
order.set('pickupOrDelivery', request.params.pickupOrDelivery);
order.set('totalBillAmount', request.params.totalBill);
return order.save().then(null, function(error) {
console.log('Creating order object failed. Error: ' + error);
return Parse.Promise.error('An error has occurred. Your credit card was not charged.' + order);
});
}
}
在日志中我得到value of recept data is good
但是创建对象失败,我收到错误消息Creating order object failed. Error: [object Object]
。如果任何一个云帮助那将是伟大的!
答案 0 :(得分:0)
我看起来像在错误消息中找到了我自己的答案。出现问题的是我需要将它指向AWS api上的新解析服务器而不是旧的解析api。