I've been looking at other Stack Overflow questions and I still can't figure mine out. I'm getting this error in the browser console:
Exception in delivering result of invoking 'formMethod1': TypeError: callback is not a function
I've put my code below and a comment on the line the error references. It seems that the "err" object isn't getting passed, but the callback is actually being called and the whole thing goes through, it just never catches the error.
submitForm1(entry,
processForm1(err,res,entry,function(err,res){
//Done processing
console.log(err); //Doesn't work
console.log(res); //Doesn't work
console.log("Done"); //Works
})
)
function submitForm1(entry, callback) {
Meteor.call('formMethod1', {
params: {
user: Meteor.user().username,
activity: entry
}
}, function(err,res){
if(err){
console.log(err) //Works
callback(err, res, entry) //This is where the error happens
} else{
callback(undefined, res, entry)
}
}
);
}
function processForm1(err, res, entry, callback) {
console.log(err); //Doesn't work
console.log(res); //Works
console.log(entry); //Works
if (err) {
if (err.error == "1001") { //Activity not found
//Handle Error
callback("Activity Not Found");
} else {
//Handle Error
callback(err.message);
}
} else { //No Errors
callback(undefined,"Submitted");
}
}
EDIT: You all got me going in the right direction. Here's the corrected code:
submitForm1(entry, function(err,res){
processForm1(err,res,entry,function(err,res){
//Done processing
console.log(err);
console.log(res);
console.log("Done");
})
});