Closed ScottAgirs closed 5 years ago
It looks like this.success() needs to be inside an if statement, the code below works.
Jobs.register({
poToUsers: function(userId, amount) {
if (userId) {
Meteor.call("sendEmailMethod", userId, amount, err => {
if (err) console.log("ERROR: [po/registry.js]: ", err);
});
this.success();
this.remove();
} else {
this.reschedule({
in: {
minutes: 5
}
});
}
}
});
Perhaps @msavin could elaborate on if this is true and maybe briefly why is this?
Yes its a JavaScript scoping issue.
You can do:
var self = this
And then call self.success() somewhere deeper in the function
Upon calling my Meteor method
doPO();
(containing SteveJobs method), I get the following console error output:$ Ohh yeah - Success! This is the result from poToUser // console.log result (ohh yeah - no Success!, lol) $ $ $ Jobs: Job failed to run due to code error: poToUser $ $ TypeError: this.success is not a function $ at toolbelt.payoutToUser (imports/startup/server/stevejobs/po/registrars/Users.js:7:12) $ ..
Register job:
Call the Job