Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
Need help to solve nodejs module.exports throws error

I have user route as below and I am importing controller in user.routes.js

//user.routes.js

const express = require('express')
const router = express.Router()
const userController = require('../controllers/user.controller')

router.get('/info', userController.getUser)

module.exports = router

Below is how I have declared user controller

//user.controller.js

const {wrapController} = require("../ErrorHandlers/catchError");
const {Api404Error} = require("../ErrorHandlers/apiErrors");

function userController() {
    const controller = {
        getUser(req, res) {
            throw new Api404Error('User not found.') //I did small correction here
        }
    }
    wrapController(controller)
    return controller
}

module.exports = userController

But I am getting this error.

Route.get() requires a callback function but got a [object Undefined]

I am new to Nodejs. Thanks for helping.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!