可能是Axios的baseURL设置错误或者请求地址不正确导致的。可以按照以下步骤检查解决:
axios.defaults.baseURL = 'http://localhost:5000/api/';
axios.get('/users')
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
在以上示例中,请求的地址为相对地址,所以会自动使用Axios的baseURL进行拼接。如果请求的地址是绝对地址,则不会拼接baseURL。
axios.get('http://localhost:5000/api/users')
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});