Home > Net >  Can't export multiple modules [ExpressJs]
Can't export multiple modules [ExpressJs]

Time:11-17

this my error: Route.get() requires a callback function but got a [object Object]

module.exports = getAccessToRoute;

I don't get an error when I export as, But

module.exports = { getAccessToRoute, getAdminAccessToken };

when i export like this i get error. I don't have problem nother middleware.

CodePudding user response:

I forgot the parentheses when calling from within another router.

const getAccessToRoute = require('../middlewares/authorization/auth');

i fixed it like this

const { getAccessToRoute } = require('../middlewares/authorization/auth');
  • Related