So, I am doing a redirection in a method call for inserting data to a collection.
However, when the redirect to the url of the newly created document page, I got this Exception in delivering result… error. If I refresh the page again, this error gone. Seem like the document wasn’t synced in the client side.
I using flow router ssr, reactjs and jagi astronomy model layer, and this is what I did:
The method call
data = blah blah..
Meteor.call('AddItem', data, (error, result) => {
if(error){
Bert.alert(error['reason'], 'danger', 'fixed-top', 'fa-frown-o' );
}else{
FlowRouter.go('/item/edit/' + result);
}
});
The Method:
Meteor.methods({
AddItem(data){
if(Roles.userIsInRole(this.userId, ['admin'])){
input = {
title : data['title'].trim(),
content : data['content'],
}
let newitem = new Space();
newsitem.set(input);
return newitem.save(function(err, id){
if(err){
throw new Meteor.Error('erro-obj', err);
}else{
return id;
}
});
console.log(returnval);
return returnval;
}
},
})
Why the newly created document object not passing to the client on redirection? But when I go manually to the page no error at all? I don’t t who to blame, flow router or mongodb?