Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export function loadAllWeather() {
- return dispatch => {
- dispatch({
- type: 'LOAD_ALL_REQUEST', // это может помочь вам, если захотите сделать прелоадер
- })
- fetch(`http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=ad7ce277ead15b2f7e1bdc6f7e6b7f3b`)
- .then(function(response) {
- if (response.status >= 400) {
- throw new Error("Bad response from server");
- }
- return response.json();
- })
- .then(function(data) {
- dispatch({
- type: LOAD_ALL_WEATHER,
- payload: data, // ваши данные с сервера
- })
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement