there are several issues with the same theme, but I could not solve my problem.
Error: Route.post() requires callback functions but got a [object Undefined]
at R
This error usually comes when you mistakenly import functions in the wrong way, or may be a spelling mistake Both the controller and the route are in some trouble.
I encountered this when I was exporting a function from the controller which was all good.
exports.addCategory = (req,res) => {}
but when I was importing it in the routes I was doing
const addCategory = require('../Controllers/Category')
instead
const {addCategory) = require('../Controllers/Category')
you see that curly braces around addCategory while importing So, I was importing the entire function, which was wrong
You are only missing
module.exports = app, or whatever you are exporting. This happened to me many times.