具有多个端点的应用 - 路由[UI5+ node.js]

发布于 2025-02-13 11:16:47 字数 541 浏览 0 评论 0原文

我确实有一个具有多个端点的应用程序,问题是,这个新端点未通过URL识别。

例如:

server.js内有get函数:

app.get('/TwoWonders', function (req, res) {
    var items = [
        {name: 'Example1', location: 'Rome'},
        {name: 'Example2', location: 'Greece'}
    ]
    res.send(items);
});

通过文件中的端口,即localhost:3000 /twoWonders我可以访问twoWonders的内容。

问题twOwonders放在单独的文件中时,但是它不起作用/无法识别。我如何使它起作用?

更新:找不到这个问题的灵魂

I do have an application with multiple endpoints, the issue is, this new endpoints aren't recognized via an url.

For example:

Within server.js there is the GET-function:

app.get('/TwoWonders', function (req, res) {
    var items = [
        {name: 'Example1', location: 'Rome'},
        {name: 'Example2', location: 'Greece'}
    ]
    res.send(items);
});

Via the port set in the file, i.e. localhost:3000/TwoWonders i could access the contents of TwoWonders.

Issue
When puting TwoWonders to a separate file, wonders.js, the url appropriate to it would be localhost:3000/wonders/TwoWonders, however it doesn't work/isn't recognized. How do i make it work ?

Update: couldnt find the soultion to this issue

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文