我需要调用两个API,并等待两个响应都返回后再分派我的操作。
我正在使用Promise.all
,但是遇到以下错误:
index.js:51 Uncaught (in promise) TypeError: # is not iterable at Function.all ()
const fetchPrices = () => Promise.resolve(getPrices());
const fetchSupplies = () => Promise.resolve(getSupply());
const fetchAll = () => Promise.all(fetchPrices(), fetchSupplies()).then((resultsArray) => {
return resultsArray;
});
// GET coins from coinmarketcap Pro API v1.
export const startGetPrices = () => dispatch => fetchAll().then((res) => {
console.log('res', res);
//...
});