首页 > 解决方案 > 如何调用 modules.export 路由作为 api?

问题描述

向大家问好!!我做了一些事情,但我认为我在 API 的时候做错了

我已经为这样的一些路由设置了我的节点 js 代码

const admin_Controllers = require('./adminControllers/controllers')
// using the admin controller from the file 
admin_Controllers(app)

就像我将应用程序作为参数发送到文件一样,我正在这样编码

module.exports = (app) => {
    app.get('/viewall', (req, res) => {
        res.send("Hello i am stuck here")
    });
}

现在的问题是我应该使用哪个路径来访问这个获取请求。

标签: javascriptnode.jsapimodule.exports

解决方案


您应该使用为该特定中间件定义的路径。

http://hostname:[port_number]/viewall

推荐阅读