javascript - 如何调用 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")
});
}
现在的问题是我应该使用哪个路径来访问这个获取请求。
解决方案
您应该使用为该特定中间件定义的路径。
http://hostname:[port_number]/viewall
推荐阅读
- javascript - 如何在不更改文本内容的情况下使用拆分
- php - 通过邮递员发送文件
- php - Guzzle6 中的 URI 模板?
- python - 如何在存储在熊猫数据框中的数组中查找字符串的再次出现
- logging - 与 Enterprise Library 一起使用时如何释放 Logger 文件处理程序?
- html - href 链接到 index.html 中的组件
- python - 在 anaconda 环境中使用子进程
- android - 如何在 Build.Gradle 中添加 SonarQube 插件并获取当前项目的报告
- java - 我怎样才能得到卷的总和?
- java - 使用 power mockito 模拟静态方法,在其构造函数中返回带有 dao 实例的单例类