I cant pass token in node js

I’ve got problem with redirect system in NodeJS. I created login site, when i’m logging in. When i check if login and password is correct i make jwt token. Then i would like to pass it into another page and redirect("/users/token")to my user page by get method. I searched a lot of sites and I’ cant solve this problem. Thank you very much My code is :

    const token = req.params.token;
    console.log("===========================");
    const body = req.body;
    const userId = req.userData.userId;

    User.findOneAndUpdate({_id: userId}, {
        $set: {
            fullname: req.body.fullname,
            university: req.body.university,
            dateofbirth: req.body.dateofbirth,
            studentid: req.body.studentid,
            course: req.body.course,
            // awardeddegree: req.body.awardeddegree,
            // degree: req.body.degree,
            verified: true,
        },

    });
    // .exec()
    // .then(result => {
    // return res.render('forms/verified', {
    //     pageTitle: 'Verification Application',
    //     path: 'form/verified',
    //     formsCSS: true,
    //     productCSS: true,
    //     token:token,

   return res.redirect("/users/token")

}));


router.post('/signup', (req, res, next) => {
    const username = req.body.username.trim();
    const password = req.body.password.trim();
    console.log("sign up Ok!!!!");
    User.find({
        username: username,

    })
        .exec()
        .then(user => {
            if (user.length >= 1) {
                return res.status(errors.USERNAME_UNAVAILABLE.status).json(errors.USERNAME_UNAVAILABLE);
            } else {
                bcrypt.hash(password, 10, (err, hash) => {
                    if (err) {
                        console.log(err)
                        res.status(generalError.status).json(generalError);

                    } else {
                        const user = new User({
                            username: username,
                            password: hash,
                            // fullname:req.body.fullname,
                            // university:req.body.university,
                            // dateofbirth:req.body.dateofbirth,
                            // studentid:req.body.studentid || null,
                            // course:req.body.course,
                            // awardeddegree:req.body.awardeddegree|| null,
                            // degree:req.body.degree|| null


                        });
                        user
                            .save()
                            .then(result => {
                                res.render('forms/login', {
                                    pageTitle: 'Login application',
                                    path: '/forms/login',
                                    formsCSS: true,
                                    productCSS: true,

                                });
                                // res.status(201).json({
                                //     message: "Ο χρήστης δημιουργήθηκε επιτυχώς."
                                //
                                // });
                            })
                            .catch(err => {
                                console.log(err);
                                res.status(generalError.status).json(generalError);

                            });
                    }
                })
            }
        })
        .catch(err => {
            console.log(err);
            res.status(generalError.status).json(generalError);

        });

});


////////////////////////
// user login //////////
////////////////////////
router.post('/login', (req, res, next) => {
    const username = req.body.username.trim();
    const password = req.body.password.trim();
    User.findOne({
        username: username
    })
        .then(user => {
            if (!user) {

                return res.status(errors.USERNAME_CONFIRMATION.status).json(errors.USERNAME_CONFIRMATION);
            }
            //  let fetchedUser = user;
            bcrypt.compare(password, user.password, (err, result) => {
                if (err) {
                    return res.status(authError.status).json(authError);

                }
                if (result) {
                    console.log(user)
                    const token = jwt.sign({
                            username: user.username,
                            userId: user._id,

                        },
                        config.secret
                    );
                    if (user.verified) {
                        if (user.token) {
                            console.log("here")
                            return res.render('forms/main', {
                                pageTitle: 'Verification Form',
                                path: 'form/verified',
                                formsCSS: true,
                                productCSS: true,
                                token: token
                            });
                        }
                        console.log("here2")

                        return res.render('forms/unverified', {
                            pageTitle: 'Main Application',
                            path: 'form/unverified',
                            formsCSS: true,
                            productCSS: true,
                            token: token

                        });

                    }
                    console.log("here 3")

                    return res.render('forms/main', {
                        pageTitle: 'Verification Form',
                        path: '/forms/main',
                        formsCSS: true,
                        productCSS: true,
                        token: token,
                        verify: true


                    });

                    // return res.status(200).json({
                    //     message: "Συνδεθήκατε με επιτυχία",
                    //     username: user.username,
                    //     status: 200,
                    //     success: true,
                    //     token:token,
                    // });
                }
                res.status(authError.status).json(authError);

            });
        })
        .catch(err => {
            console.log(err);
            res.status(generalError.status).json(generalError);

        });

});

////////////////////////
// Get all non admin ///
////////////////////////
router.get('/login', asyncHandler(async (req, res, next) => {


    return res.render('forms/login', {
        pageTitle: 'Login Form',
        path: '/forms/login',
        formsCSS: true,
        productCSS: true,

    });
}));

router.get('/registration', asyncHandler(async (req, res, next) => {

    return res.render('forms/registration', {
        pageTitle: 'Registration Form',
        path: 'form/registration',
        formsCSS: true,
        productCSS: true,

    });


}));
router.post('/main', asyncHandler(async (req, res, next) => {

    console.log("main")
    return res.render('forms/main', {
        pageTitle: 'Main Application',
        path: 'form/main',
        formsCSS: true,
        productCSS: true,

    });


}));
router.get('/verify', asyncHandler(async (req, res, next) => {

    return res.render('forms/verified', {
        pageTitle: 'Verified Application',
        path: 'form/verified',
        formsCSS: true,
        productCSS: true,


    });
}));
router.get('/unverified', asyncHandler(async (req, res, next) => {

    return res.render('forms/unverified', {
        pageTitle: 'unverified Application',
        path: 'form/unverified',
const token = req.params.token;
    console.log("===========================");
    const body = req.body;
    const userId = req.userData.userId;

    User.findOneAndUpdate({_id: userId}, {
        $set: {
            fullname: req.body.fullname,
            university: req.body.university,
            dateofbirth: req.body.dateofbirth,
            studentid: req.body.studentid,
            course: req.body.course,
            // awardeddegree: req.body.awardeddegree,
            // degree: req.body.degree,
            verified: true,
        },

    });
    // .exec()
    // .then(result => {
    // return res.render('forms/verified', {
    //     pageTitle: 'Verification Application',
    //     path: 'form/verified',
    //     formsCSS: true,
    //     productCSS: true,
    //     token:token,

   return res.redirect("/users/token")

}));


router.post('/signup', (req, res, next) => {
    const username = req.body.username.trim();
    const password = req.body.password.trim();
    console.log("sign up Ok!!!!");
    User.find({
        username: username,

    })
        .exec()
        .then(user => {
            if (user.length >= 1) {
                return res.status(errors.USERNAME_UNAVAILABLE.status).json(errors.USERNAME_UNAVAILABLE);
            } else {
                bcrypt.hash(password, 10, (err, hash) => {
                    if (err) {
                        console.log(err)
                        res.status(generalError.status).json(generalError);

                    } else {
                        const user = new User({
                            username: username,
                            password: hash,
                            // fullname:req.body.fullname,
                            // university:req.body.university,
                            // dateofbirth:req.body.dateofbirth,
                            // studentid:req.body.studentid || null,
                            // course:req.body.course,
                            // awardeddegree:req.body.awardeddegree|| null,
                            // degree:req.body.degree|| null


                        });
                        user
                            .save()
                            .then(result => {
                                res.render('forms/login', {
                                    pageTitle: 'Login application',
                                    path: '/forms/login',
                                    formsCSS: true,
                                    productCSS: true,

                                });
                                // res.status(201).json({
                                //     message: "Ο χρήστης δημιουργήθηκε επιτυχώς."
                                //
                                // });
                            })
                            .catch(err => {
                                console.log(err);
                                res.status(generalError.status).json(generalError);

                            });
                    }
                })
            }
        })
        .catch(err => {
            console.log(err);
            res.status(generalError.status).json(generalError);

        });

});


////////////////////////
// user login //////////
////////////////////////
router.post('/login', (req, res, next) => {
    const username = req.body.username.trim();
    const password = req.body.password.trim();
    User.findOne({
        username: username
    })
        .then(user => {
            if (!user) {

                return res.status(errors.USERNAME_CONFIRMATION.status).json(errors.USERNAME_CONFIRMATION);
            }
            //  let fetchedUser = user;
            bcrypt.compare(password, user.password, (err, result) => {
                if (err) {
                    return res.status(authError.status).json(authError);

                }
                if (result) {
                    console.log(user)
                    const token = jwt.sign({
                            username: user.username,
                            userId: user._id,

                        },
                        config.secret
                    );
                    if (user.verified) {
                        if (user.token) {
                            console.log("here")
                            return res.render('forms/main', {
                                pageTitle: 'Verification Form',
                                path: 'form/verified',
                                formsCSS: true,
                                productCSS: true,
                                token: token
                            });
                        }
                        console.log("here2")

                        return res.render('forms/unverified', {
                            pageTitle: 'Main Application',
                            path: 'form/unverified',
                            formsCSS: true,
                            productCSS: true,
                            token: token

                        });

                    }
                    console.log("here 3")

                    return res.render('forms/main', {
                        pageTitle: 'Verification Form',
                        path: '/forms/main',
                        formsCSS: true,
                        productCSS: true,
                        token: token,
                        verify: true


                    });

                    // return res.status(200).json({
                    //     message: "Συνδεθήκατε με επιτυχία",
                    //     username: user.username,
                    //     status: 200,
                    //     success: true,
                    //     token:token,
                    // });
                }
                res.status(authError.status).json(authError);

            });
        })
        .catch(err => {
            console.log(err);
            res.status(generalError.status).json(generalError);

        });

});

////////////////////////
// Get all non admin ///
////////////////////////
router.get('/login', asyncHandler(async (req, res, next) => {


    return res.render('forms/login', {
        pageTitle: 'Login Form',
        path: '/forms/login',
        formsCSS: true,
        productCSS: true,

    });
}));

router.get('/registration', asyncHandler(async (req, res, next) => {

    return res.render('forms/registration', {
        pageTitle: 'Registration Form',
        path: 'form/registration',
        formsCSS: true,
        productCSS: true,

    });


}));
router.post('/main', asyncHandler(async (req, res, next) => {

    console.log("main")
    return res.render('forms/main', {
        pageTitle: 'Main Application',
        path: 'form/main',
        formsCSS: true,
        productCSS: true,

    });


}));
router.get('/verify', asyncHandler(async (req, res, next) => {

    return res.render('forms/verified', {
        pageTitle: 'Verified Application',
        path: 'form/verified',
        formsCSS: true,
        productCSS: true,


    });
}));
router.get('/unverified', asyncHandler(async (req, res, next) => {

    return res.render('forms/unverified', {
        pageTitle: 'unverified Application',
        path: 'form/unverified',
        formsCSS: true,
        productCSS: true,

    });
}));


router.get('/token',verify, asyncHandler(async (req, res, next) => {
    const _id = req.params._id
    const token = req.params.token;
    let user = await User.findById(_id).exec();


    res.render('forms/token',
        {
            _id: _id,
            // verified: true,
            token: token

        }

    )

    // return res.render('forms/token', {
    //     pageTitle: 'Token Application',
    //     path: 'form/token',
    //     formsCSS: true,
    //     productCSS: true,
    // });
    //res.send({message:"works"})
}));


module.exports = router;``` 

Hi John, this does not seem to be an issue with the Couchbase NodeJS SDK. May I suggest posting this question to StackOverflow as I believe you will have much more success there. Unless a community member decides to dig into this question our NodeJS folks here at Couchbase typically only answer questions related to the NodeJS SDK.

You could check out similar related questions first on StackOverflow like: