【发布时间】:2020-02-04 17:28:39
【问题描述】:
在我的组件中
axios({
method: 'get',
url: `${SERVER_URL}crawler/get-customer/${uniqueId}`,
}).then(function (response) {
if(response.data){
console.log("response",response);
responseData = response.data;
dispatch({ type: 'SET_IMG', payload: { url: responseData.logo_url } });
}
},[]);
应有的响应,但调度是递归的,几乎让我的浏览器崩溃,并且数据“url”没有更新
【问题讨论】:
-
你是如何以及在哪里通过 axios 执行你的 api 请求的
-
使用django本地服务器,api请求没有问题,我用useEffect()钩子解决了这个问题。感谢您的宝贵时间。
标签: javascript reactjs react-hooks