Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

192
Vistas
how get the req, res objects in the callbacks

I like to get the req, res, next objects outside the middleware function.

sample middleware - sample.js:

var app = express();
....
.....
....
var updateUserInput = {
   init:function(){
       get_data_from_db(params, function(){
           // want req, res here.
       })
   }
}

const processUserInput = function(req, res, next){
   updateUserInput.init();
}
module.exports = processUserInput;
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You should be able to pass those into the init function right away:

var updateUserInput = {
   init:function(req,res,next){
       get_data_from_db(params, function(){
           // You will have req and res available here
           // finish processing and call next()
       })
   }
}

const processUserInput = function(req, res, next){
   updateUserInput.init(req,res,next);
}
about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda