Skip to content

Commit e175e7b

Browse files
committed
add json check
1 parent 348434c commit e175e7b

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

spec/RestQuery.spec.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,11 @@ describe('RestQuery.each', () => {
412412
});
413413

414414
Parse.Cloud.afterSave('TestObject2', function (req) {
415-
const jsonObject = req.object.toJSON();
416-
delete jsonObject.todelete;
417-
delete jsonObject.tobeaddbeforeandremoveafter;
418-
jsonObject.toadd = true;
419-
420-
return jsonObject;
415+
expect(req.object.get('tobeaddbefore')).toBeTruthy();
416+
expect(req.object.get('tobeaddbeforeandremoveafter')).toBeTruthy();
417+
req.object.set('todelete', undefined);
418+
req.object.set('tobeaddbeforeandremoveafter', undefined);
419+
req.object.set('toadd', true);
421420
});
422421

423422
rest.create(config, nobody, 'TestObject2', { todelete: true, tokeep: true }).then(response => {

src/RestWrite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1536,7 +1536,7 @@ RestWrite.prototype.runAfterSaveTrigger = function () {
15361536
this.context
15371537
)
15381538
.then(result => {
1539-
const object = result && typeof result === 'object' ? result : updatedObject;
1539+
const object = result?._toFullJSON ? result : updatedObject;
15401540
this.response.response = this._updateResponseWithData(object._toFullJSON(), this.data);
15411541
})
15421542
.catch(function (err) {

0 commit comments

Comments
 (0)