diff --git a/part2/2.12-2.14/src/App.js b/part2/2.12-2.14/src/App.js index 27148bf..ca83c2f 100644 --- a/part2/2.12-2.14/src/App.js +++ b/part2/2.12-2.14/src/App.js @@ -20,16 +20,16 @@ const App = () => { useEffect(() => { console.log(ResultList) - if (ResultList.length > 0 ) { - const capital = ResultList[0].capital - const apistring = `http://api.weatherstack.com/current?access_key=9482b8f61c984f8e1988759e020d133e&query=${capital}` + if (ResultList.length === 1 ) { + const capital = ResultList[0].capital.replace(/\s/g, '+') + console.log(capital) + const apistring = `http://wttr.in/${capital}?format=j1` console.log(capital, apistring) axios .get(apistring) .then(response => { setWeatherdata(response.data) }) - console.log(WeatherData) } }, [ResultList]) diff --git a/part2/2.12-2.14/src/components/Country.js b/part2/2.12-2.14/src/components/Country.js index 71f7e32..2b96245 100644 --- a/part2/2.12-2.14/src/components/Country.js +++ b/part2/2.12-2.14/src/components/Country.js @@ -31,7 +31,8 @@ const CountryLongList = ({data, onClick,weather}) => { ); } const CountryDetail = ({data,weather}) => { - console.log(weather) + console.log("Data", data) + console.log("Length", data.length) return (
Temperature: {weather.current.temperature} Celcius
-Wind: {weather.current.wind_speed} mph {weather.current.wind_degree} {weather.current.wind_dir}
+Temperature: {temperature} Celcius
+Wind: {windspeed} km/h, Direction {winddirection}
+