Expres : Editing app.param() for multiple routes

I edit this todo app and make a multiple topics version of it. Like todos for X, todos for Y, todos for Z…

However i couldn’t find a proper way to edit this part :

app.param(‘task_id’,function(req,res,next,taskId){

req.db.tasks.findById(taskId,function(error,task){
    if(error) return next(error);
    if(!task) return next(new Error('Task is not found'));

    //if there's data, we store it in the request and proceed to the next middleware:
    //
    req.task = task;
    return next();
}); 

});

Because instead of tasks , i have now xtopic,ytopic,…

So if i add a task to Y,Z, or another topic, it should restored in that part. But when i try to mark “done” a task in Y, or Z, it creates an error. How can i restore all tasks by its topic?

This is how it looks like : https://postimg.org/gallery/2r8uva4pa/

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.