Note: There was no problem, until I added docs_router.js
docs_router.js
const { control_docs_v1, ipManager } = require('../controllers/indexer')
const router = require('express').Router()
router.get('/v1', ipManager, control_docs_v1)
module.exports = router
location.js
const { ipManager, sendData } = require('../controllers/indexer')
const router = require('express').Router()
router.get('/weather/:loc', ipManager, sendData)
module.exports = router
indexer.js
const location = require('./location')
const docs_router = require("./docs_router")
module.exports = {
location,
docs_router
}
In the entry file, index.js
I have,
app.use("path1", location)
app.use("path", docs_router)
Is there any issue with exporting multiple router object?
How to use router
in righth way?
Finally solved.
I made these changes.
docs_router.js
const { control_docs_v1, ipManager } = require('../controllers/indexer')
const router = require('express').Router()
router.get('/v1', ipManager.ipManager, control_docs_v1.control_docs_v1)
module.exports = router
location.js
const { ipManager, sendData } = require('../controllers/indexer')
const router = require('express').Router()
router.get('/weather/:loc', ipManager.ipManager, sendData)
module.exports = router
Doing this resolved the error.