I want to get the value of the parameter articlePageId of the following url, but I have tried several ways to get it. I want to ask for help from my predecessors here. I hope I can take the time to give you some advice. Thank you!
https://localhost:8090/articlePage.html?articlePageId="+item.ID
console.log(fullUrl) // http://localhost:8090/
console.log(req.path) // /
console.log(req.params) // {}
console.log(req.query.articlePageId) // undefined
The articlePageId.html, link reaches this page and sends the request to the background via vue-resource
window.onload = () => {
const vm = new Vue({
el: "-sharpapp",
data: {
dataGroup: [],
},
methods: {
renderArticle() {
this.$http.get("/", {
}).then((res) => {
this.dataGroup = res.data;
}, (res) => {
alert(res.status)
})
},
},
created() {
this.renderArticle("/")
}
})
}
The background receives the get request, originally hoping to analyze the value of the url extracted articlePageId to retrieve the article from the database, but I don"t know why I can"t read the parameters after http://localhost:8090/
.router.use("/articlePage",(req,res)=>{
db.query(`SELECT * FROM articles_table WHERE ID="${pageId.id}"`,(err,page)=>{
if(err){
console.error(err);
res.status(500).send("database error").end();
}else{
res.send(page);
}
})
})
Ps: already uses body-parser on the primary server