我在 heroku 上有一個快速服務器,但不知何故我無法使引數化的 get 請求作業。
var app = express();
app.use(cors());
app.use(express.json());
app.use(express.urlencoded());
const port = process.env.PORT || 3000;
app.listen(port, () =>
console.log("Server running on port:" port));
app.get("/", (req, res, next) => {
res.send("Hello")
});
app.get("/get-checkout/:contract/:nft-id", (req, res, next) => {
res.send("checkout")
});
第一個 get 有效,但第二個導致“無法獲取”錯誤,每當我嘗試獲取
https://myserver.herokuapp.com/get-checkout/test/test
我看過很多例子,但我無法弄清楚我做錯了什么。
uj5u.com熱心網友回復:
好吧,看來,您不能在引數名稱中使用“-”符號。考慮到您不能在變數名稱中使用“-”,這是有道理的。
所以這將起作用:
app.get("/get-checkout/:contract/:nftid", (req, res, next) => {
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/333165.html
