我想向http://localhost:5000/trackers/{{id}}发送一个请求。我试图通过axios传递参数,但是当我检查API时,请求只传递给http://localhost:5000/trackers/。我怎么才能解决这个问题?
Axios代码:
mounted() {
axios.get('http://localhost:5000/trackers/', {params : { id } })
.then((resp ) => console.log(resp.data))
.catch((err) => console.log(err.response))
let id = localStorage['id']
return{
id
}如何通过axios传递查询参数--这是我的API代码:

我还没有在我的API中为‘/tracker/{id}’创建路由。我首先尝试检查我的VueJS代码中的路由是否有效。
发布于 2022-08-15 10:45:54
如果你只需要请求http://localhost:5000/trackers/{{id}},
您可以这样构建请求url:
...
axios.get('http://localhost:5000/trackers/' + id)
...发布于 2022-08-16 04:07:36
你能用下面的代码试一次吗?
mounted() {
axios.get(`http://localhost:5000/trackers/${id}`)
.then((resp ) => console.log(resp.data))
.catch((err) => console.log(err.response))
let id = localStorage['id']
return{
id
}
}https://stackoverflow.com/questions/73359863
复制相似问题