I'm trying to make use of the afterSave
hook in Parse.
However even a simple print out of the ID from the object that was just saved does not show in logs, and if
statements do not pass to allow other methods to be performed. The relevant code:
Parse.Cloud.afterSave(Parse.User, function(request) {
Parse.Cloud.useMasterKey();
var user = request.object;
console.log('After save for user ID: ', user.id);
if (!user.existed() && user.get('isTrainer')) {
// does not enter here
The log that prints out has no ID, just the string I typed. I also tried printing out the request object but the Parse logging system doesn't seem capable of printing out objects which is unfortunate. It also doesn't enter the if
statement because using get
also returns no information.
Anyone have an idea of why this might be?
For completeness here is the object so you can see its being saved correctly:
v31 after_save triggered for _User for user PlVMz2zCfC:
Input: {"object":{"createdAt":"2015-12-24T21:01:01.678Z","email":"yui@bb.bb","firstName":"Pppp","isTrainer":true,"lastName":"Pop","objectId":"PlVMz2zCfC","phone":"(555) 555-5555","trainer":{"__type":"Relation","className":"Trainer"},"updatedAt":"2015-12-24T21:01:01.678Z","username":"yui@bb.bb"}}
Result: Success