【发布时间】:2020-09-18 15:28:34
【问题描述】:
谁能帮我看看如何使用 Axios 在 ReactJS 中调用 Mocky API?
这是我的 CodeSandbox 链接:MockyAPIReactJS
我已经在上下文 API 中调用了该 API。 只是想 console.log 数据,我会处理它。
userData=async()=>{
await axios.get('http://www.mocky.io/v2/5ba8efb23100007200c2750c')
.then(res=>console.log(res.data))
.catch(err=>console.log("UserData Error",err))
}
componentDidMount(){
this.userData()
}
【问题讨论】:
-
你能把问题中的相关代码也贴出来吗?
标签: javascript reactjs