У меня проблема с цепочкой обещаний с использованием axios:
export const get5DayForecast = () => {
return axios.get('http://localhost:4000/api/weatherForecast').then(res => {
return res;
}).catch(err => {
return err;
});
};
export const load5dayForecast = () => {
return (dispatch) => {
return get5DayForecast.then(res => {
dispatch(load5dayForecastSuccess(res.data));
}).catch(err => {
throw (err);
});
};
С другой стороны, этот подход работает:
export const load5dayForecast = () => {
return (dispatch) => {
return axios.get('http://localhost:4000/api/weatherForecast').then(res => {
dispatch(load5dayForecastSuccess(res.data));
}).catch(err => {
throw (err);
});
};
}
Это часть действий редуктора реагирования.Что мне не хватает?