Reputation: 442
I'm uploading a picture to parse.com using the following two ways. The first one using promises works, but the other doesn't. Am I missing something very basic?
Method 1:
var parseFile = new Parse.File(name, file);
parseFile.save().then(function (){
console.log('Picture has been successfully saved.');
callback(pictype, parseFile);
}, function (error){
console.log('Picture cannot be saved.', error.toString());
});
Method 2:
var parseFile = new Parse.File(name, file);
parseFile.save(null, {
success: function () {
console.log('Picture has been successfully saved.');
callback(pictype, parseFile);
},
error: function (error) {
console.log('Picture cannot be saved.', error.toString());
}
});
Upvotes: 1
Views: 102
Reputation: 9929
It depends on how the save method on Parse.File is implemented. It clearly returns a promise since that code works...it probably does not support the success and error syntax. Your code will not fail on it however it just doesn't work.
Edit: looking at the documentation you need to specify the options object (containing the success and error methods) as first argument. That is where you now specify null.
Upvotes: 1