![](/img/trans.png)
[英]ExpressJS cannot get /route in Openshift, but locally it is working
[英]GET method not working on specific route in ExpressJS
當我嘗試使用/:user
獲取數據時,function 沒有在特定路由中運行,誰能幫我弄清楚這里的錯誤是什么?
const express = require("express");
const app = express();
const mongoose = require("mongoose");
const {accountSC,catalogSC} = require("./schema");
let dburl = **database url**
app.use(express.json());
mongoose.connect(dburl);
app.get("/catalog", async (req, res) => {
//some func inside it
});
app.get("/:catalog/:id", async (req, res) => {
//some func inside it
});
app.get("/:user", async (req, res) => {
//some func inside it
});
基本上您的/catalog
和/:user
由於結構相同。 :user
值也可以是catalog
。 因此,嘗試不同的路由命名方法( /info/:user
)。
謝謝你。
更新:試試這個。
app.get("/catalog", async (req, res) => {
//some func inside it
});
app.get("/catalog/:catalog/:id", async (req, res) => {
//some func inside it
});
app.get("/info/:user", async (req, res) => {
//some func inside it
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.