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.
21 lines
779 B
21 lines
779 B
import { getFavoriteCityStorage } from "../../asyncStorange/getFavoriteCityStorage";
|
|
import { City } from "../../data/stub";
|
|
import { setFavoriteCity } from "./setFavoriteCity";
|
|
|
|
export const getFavoriteCity = () => {
|
|
return async dispatch => {
|
|
try {
|
|
const json = await getFavoriteCityStorage()
|
|
if (json!=null){
|
|
dispatch(setFavoriteCity(new City(json["name"], json["latitude"], json["longitude"])))
|
|
}
|
|
else{
|
|
dispatch(setFavoriteCity(null))
|
|
}
|
|
} catch (error) {
|
|
console.log('Error---------', error);
|
|
//You can dispatch to another action if you want to display an error message in the application
|
|
//dispatch(fetchDataRejected(error))
|
|
}
|
|
}
|
|
} |