You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
617 B
18 lines
617 B
import { WeatherIcon } from "../data/stub";
|
|
import { setWeatherIconList } from "../redux/actions/ActionIcon";
|
|
|
|
export const getWeathersIconList = () => {
|
|
return async dispatch => {
|
|
try {
|
|
const iconsPromise = await fetch('https://iut-weather-api.azurewebsites.net/condition-codes');
|
|
const iconsListJson = await iconsPromise.json();
|
|
const iconsList: WeatherIcon[] = iconsListJson.map(elt => new WeatherIcon(elt["name"], elt["imageUri"]));
|
|
// console.log(iconsList);
|
|
dispatch(setWeatherIconList(iconsList));
|
|
} catch (error) {
|
|
console.log('Error---------', error);
|
|
}
|
|
}
|
|
}
|
|
|