10.使用axios实现真实的api请求
export const getArticle = () =>{
return dispatch =>{
setTimeout(()=>{
// dispatch(eat('煎饼'))
dispatch(()=>{
axios.get('/v1/article/list').then(res=>{
console.log('article',res)
})
})
},2000)
}
}
解决跨域问题
1.
npm run eject
2.
在package.json 文件末尾添加 "proxy": "http://api.shudong.wang"
3.
axios.get('/v1/article/list').then(res=>{
console.log('article',res)
})