在学习vue的过程中,使用axios发起get请求,代码如下:
getProduct(){
axios.get('https://www.easy-mock.com/mock/5d40032d6a3ae527e747fea9/example/itlike/shop').then((response)=>{
console.log(response)
}).catch((error)=>{
console.log(error.response);
alert('网络出现异常!');
})
}
报错:
原因是:
解决方法:
先在浏览器中访问一下,访问过后再刷新项目即可正常获取。