Reputation: 11
What is wrong with this code?:
Parse.Cloud.define("insertCouponReview", function(request, response){
var ReviewClass = Parse.Object.extend("Review");
var newReview = new ReviewClass();
var CouponClass = Parse.Object.extend("Coupon");
var coupon = new CouponClass( { objectId: request.params.couponId });
var UserClass = Parse.Object.extend("_User");
var user = new UserClass( { objectId: request.params.userId });
newReview.set( "couponId" , coupon );
newReview.set( "userId" , user);
newReview.set( "reviewTitle" , request.params.reviewTitle);
newReview.set( "comment" , request.params.comment );
newReview.set( "numberOfStars" , request.params.numberOfStars);
newReview.save({
sucess:function( ){
response.success("Ok");
},
error: function(){
response.error("Erro");
}
});
});
It save correctly on Parse. But I still got the error. x) I'm new on JS and Parse Cloud Code...
Upvotes: 1
Views: 68
Reputation: 3089
The problem appears to be the typo sucess
of the word success
which leads to the save success block not being called.
newReview.save({
sucess:function( ){
response.success("Ok");
},
error: function(){
response.error("Erro");
}
});
In particular, the problem is this line
sucess:function( ){
Change it to this and you should be good to go.
success: function(){
Upvotes: 1