我已经调试这段代码一段时间了,但运气不佳:
async getEvents() {
try {
let response = await axios.get("http://localhost:8000/events/");
console.log(response);
return response.data;
} catch (error) {
console.error(error);
}
}
完整的代码示例来自:https://auth0.com/blog/how-to-make-secure-http-requests-with-vue-and-express/
我在访问调用 API 端点的站点时收到错误:
Error: Request failed with status code 404
at createAxiosError (utils.js?c786:148)
at Object.settle (utils.js?c786:127)
at handleRequest (handle_request.js?da0c:126)
at eval (index.js?94db:26)
at new Promise (<anonymous>)
at MockAdapter.eval (index.js?94db:25)
at dispatchRequest (dispatchRequest.js?5270:52)
如果我只是在浏览器中复制 url (http://localhost:8000/events/),我会收到正确的数据。我试过使用和不使用斜杠。 我是否误解了错误消息,我应该查看其他地方吗?