Is there any way to nest/ call a route inside another route in node JS and express JS?


I want to automatically execute second route after the first route executed.
For example:
I have my first route'/signup', async (req, res) => {

and my second route'/signupLog', async (req, res) => {

So i want to call my second route automatically just after the first route because the second route will take some values from first route and calculate them and have some new fields in it to fill with the calculations from first route.


Why don’t extract the second route as function and call it ?

const secondRoute = async (req, res) => {
}'/signup', async (req, res) => {
   await secondRoute(req, res);
}'/signupLog', secondRoute)

Answered By – BENARD Patrick

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published