簡體   English   中英

表達返回空參數的嵌套路由

[英]Express nested routes returning empty params

我有這樣的事情:

localhost:8000/api/news?category=tech

我目前有一個用於 /api 部分的路由器和另一個用於 /api/news 的路由器。

但是當我嘗試在 /api/news 路由器中打印 req.params 時,它並沒有像我想象的那樣顯示 { "category": "tech" } 。

如果你想獲得參數,那么。

const handleIt =  ( req,res)=> {
console.log(req.body)
console.log("POSE",req.params)
}
routes.post('/api/news/:category',handleIt)
   

也稱它使用

localhost:8000/api/news/tech 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM