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.

1 line
3.6 KiB

{"ast":null,"code":"import _asyncToGenerator from \"@babel/runtime/helpers/asyncToGenerator\";\nimport { City, Weather } from \"../../data/stub\";\nimport { setWeather } from \"./setWeather\";\nexport var getWeather = function getWeather(city) {\n return function () {\n var _ref = _asyncToGenerator(function* (dispatch) {\n try {\n var promise = yield fetch('https://iut-weather-api.azurewebsites.net/weather/city/name/' + city.name);\n var weatherJson = yield promise.json();\n var weather = new Weather(weatherJson[\"at\"], weatherJson[\"visibility\"], weatherJson[\"weatherType\"], weatherJson[\"weatherDescription\"], weatherJson[\"temperature\"], weatherJson[\"temperatureFeelsLike\"], weatherJson[\"humidity\"], weatherJson[\"windSpeed\"], weatherJson[\"pressure\"], new City(weatherJson[\"city\"][\"name\"], weatherJson[\"city\"][\"latitude\"], weatherJson[\"city\"][\"longitude\"]));\n console.log(weather);\n dispatch(setWeather(weather));\n } catch (error) {\n console.log('Error---------', error);\n }\n });\n return function (_x) {\n return _ref.apply(this, arguments);\n };\n }();\n};","map":{"version":3,"names":["City","Weather","setWeather","getWeather","city","dispatch","promise","fetch","name","weatherJson","json","weather","console","log","error"],"sources":["/Users/thomaschazot/Documents/But2A/LaSuperMeteo/iut-expo-starter/redux/actions/getWeather.ts"],"sourcesContent":["import { getFavoriteCityStorage } from \"../../asyncStorange/getFavoriteCityStorage\";\nimport { City, Weather } from \"../../data/stub\";\nimport { setFavoriteCity } from \"./setFavoriteCity\";\nimport { setWeather } from \"./setWeather\";\n\nexport const getWeather = (city: City) => {\n return async dispatch => {\n try {\n \n const promise = await fetch('https://iut-weather-api.azurewebsites.net/weather/city/name/'+city.name);\n const weatherJson = await promise.json();\n \n const weather = new Weather(weatherJson[\"at\"], weatherJson[\"visibility\"], weatherJson[\"weatherType\"], weatherJson[\"weatherDescription\"], weatherJson[\"temperature\"], weatherJson[\"temperatureFeelsLike\"], weatherJson[\"humidity\"], weatherJson[\"windSpeed\"], weatherJson[\"pressure\"], new City(weatherJson[\"city\"][\"name\"], weatherJson[\"city\"][\"latitude\"], weatherJson[\"city\"][\"longitude\"]));\n \n console.log(weather)\n dispatch(setWeather(weather));\n\n } catch (error) {\n console.log('Error---------', error);\n //You can dispatch to another action if you want to display an error message in the application\n //dispatch(fetchDataRejected(error))\n }\n }\n }"],"mappings":";AACA,SAASA,IAAI,EAAEC,OAAO;AAEtB,SAASC,UAAU;AAEnB,OAAO,IAAMC,UAAU,GAAG,SAAbA,UAAU,CAAIC,IAAU,EAAK;EACtC;IAAA,6BAAO,WAAMC,QAAQ,EAAI;MACvB,IAAI;QAEE,IAAMC,OAAO,SAASC,KAAK,CAAC,8DAA8D,GAACH,IAAI,CAACI,IAAI,CAAC;QACrG,IAAMC,WAAW,SAASH,OAAO,CAACI,IAAI,EAAE;QAExC,IAAMC,OAAO,GAAG,IAAIV,OAAO,CAACQ,WAAW,CAAC,IAAI,CAAC,EAAEA,WAAW,CAAC,YAAY,CAAC,EAAEA,WAAW,CAAC,aAAa,CAAC,EAAEA,WAAW,CAAC,oBAAoB,CAAC,EAAEA,WAAW,CAAC,aAAa,CAAC,EAAEA,WAAW,CAAC,sBAAsB,CAAC,EAAEA,WAAW,CAAC,UAAU,CAAC,EAAEA,WAAW,CAAC,WAAW,CAAC,EAAEA,WAAW,CAAC,UAAU,CAAC,EAAE,IAAIT,IAAI,CAACS,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,EAAEA,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,EAAEA,WAAW,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;QAE/XG,OAAO,CAACC,GAAG,CAACF,OAAO,CAAC;QACpBN,QAAQ,CAACH,UAAU,CAACS,OAAO,CAAC,CAAC;MAEnC,CAAC,CAAC,OAAOG,KAAK,EAAE;QACdF,OAAO,CAACC,GAAG,CAAC,gBAAgB,EAAEC,KAAK,CAAC;MAGtC;IACF,CAAC;IAAA;MAAA;IAAA;EAAA;AACH,CAAC"},"metadata":{},"sourceType":"module"}