我正在进行一个React原生API调用.
从理论上讲,它应该有效-
import API from "../../utils/API";
componentDidMount() {
let merchantId = this.props.merchant.id;
let api = new API(this.props.gatheredTokens);
let self = this;
api.setRetry(10);
api
.get("merchantMessages", { repl_str: merchantId })
.then(response => this.merchantMessageConfiguration(response.data))
.catch(function (error) {
console.log(error);
})
.finally(function () {
self.state.list.push(
<Card
merchant={self.props.merchant}
key={self.props.merchant.id}
bubblemsg={self.state.bubblemsg}
/>
);
})
.finally(function () {
self.merchantNoticeLoading(self);
});
}
然而,我得到了以下错误:
是什么导致了这个错误?代码看起来有效.
下面是get的要点:
get(API, params = this.defaultParams) {
this.call = "GET";
let constructedURL = this.constructURL(API, params);
axiosRetry(axios, { retries: this.retry });
return axios.get(constructedURL, this.config);
}