https://www.freecodecamp.com/challenges/show-the-local-weather
Open Weather Map API๋ฅผ ์ฌ์ฉํ์ฌ ์ง์ญ ๋ ์จ ์ฑ๋ฆฐ์ง ๊ถ์ฅ ์ฌํญ์ ํ์ํฉ๋๋ค. ์ง๊ธ๊น์ง ์ ์๋ํ์ต๋๋ค. ์ด์ "pen.js : 22 ํผํฉ ์ฝํ ์ธ : [...]์ ํ์ด์ง๊ฐ HTTPS๋ฅผ ํตํด๋ก๋๋์์ง๋ง ์์ ํ์ง ์์ XMLHttpRequest ์๋ ํฌ์ธํธ๋ฅผ ์์ฒญํ์ต๋๋ค. ' http://api.openweathermap.org/data/2.5/ weather? lat = 30.281903699999997 & lon = -97.73883819999999 & appid = 41bf32baf1dc0b1bb46d120a3cbdbc57 '.์ด ์์ฒญ์ ์ฐจ๋จ๋์์ต๋๋ค. ์ฝํ ์ธ ๋ HTTPS๋ฅผ ํตํด ์ ๊ณต๋์ด์ผํฉ๋๋ค. "
// If relevant, paste all of your challenge code in here
@anthkris ์ด๊ฒ์ # 8141๋ก ์์ ๋์์ต๋๋ค.
๋ณ๊ฒฝ ์ฌํญ์ ๋ฉฐ์น ๋ด์ ๊ธฐ๋ณธ ์น ์ฌ์ดํธ์ ์ ์ฉ๋ฉ๋๋ค.
ํด๊ฒฐ ๋ฐฉ๋ฒ์ผ๋ก ๋ค์๊ณผ ๊ฐ์ด CodePen ๋งํฌ์ http
๋ฒ์ ์์ฌ์ญ์์ค.
http://codepen.io/FreeCodeCamp/full/bELRjV
์ฑ๋ฆฐ์ง์ https
๋งํฌ๊ฐ ์๋๋๋ค.
๋งํฌ๋ ์์ ์ฌํญ์ด ๊ธฐ๋ณธ ์น ์ฌ์ดํธ์ ๋๋ฌํ๋ ์ฆ์ ์ ๋ฐ์ดํธ๋ฉ๋๋ค.
Chrome ๋ฐ Firefox์์ ๋งํฌ์ http ๋ฒ์ ์ ์ด ๋๋ OpenWeather API์ ๋ํ http ํธ์ถ์ด ์ฐจ๋จ๋ฉ๋๋ค. ์ด๋ฏธ Local Weather ํ๋ก์ ํธ๋ฅผ ๋ง์ณค์ง๋ง Codepen์์ ์ด์ ๊ฐ์ ํ๋ก์ ํธ๋ฅผ ์ ์ถํ ์ ์์ต๋๋ค. URL์ Safari์์ ๋ณผ ๋ ์ ์๋ํฉ๋๋ค. ๋ด ์๋ฒ์์ ํธ์คํ ๋๋์ด ํ๋ก์ ํธ๋ฅผ ์ ์ถํ๊ฑฐ๋ SSL์ ์ง์ํ๋ ๋ค๋ฅธ ๋ฌด๋ฃ ๋ ์จ API๋ฅผ ์ฐพ๋ ๊ฒ๋ง ์๊ฐํ ์์์์ต๋๋ค.
@ j7an # 7853์ ๋ํ ํ ๋ก ์ฐธ์กฐ
์ฌ์ ํ ์ฐจ๋จ๋จ
@rolandocz ์ฌ๊ธฐ @ 149203์ ์ํด ์ธ๊ธ ๋ Forecast.io๋ฅผ ์ฌ์ฉํด๋ณด์ญ์์ค : https://github.com/freeCodeCamp/freeCodeCamp/issues/7853#issuecomment -222315358
๋๋ ์ฌ๊ธฐ์์ ํด๊ฒฐ์ฑ ์ ์๋ ํ ์ ์์ต๋๋ค : https://forum.freecodecamp.com/t/local-weather-api-for-people-stuck-because-of-the-https-request/50274/17?u=j7an
์ฌ์ ํ ์ฐจ๋จ๋จ
https://cors-anywhere.herokuapp.com/
์ด๊ธฐ URL ์์ ๋ฃ์ผ๋ฉด ์ ์๊ฒ ํจ๊ณผ์ ์ด์์ต๋๋ค.
๋๋์ด :)
@ risingmoon77 ์, ์ ๋ฅผ ์ํด ์ ์๋ํฉ๋๋ค.
$.getJSON("https://cors-anywhere.herokuapp.com/http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+lon+"&appid=1c48b076cbce09ca93cfff52b6c839c1",function(json){
// other code goes here
}
@raisedadead codepen์ HTTP ์์ฒญ์ HTTPS๋ก ์๋ ๋ฆฌ๋๋ ์ ํ๋ฏ๋ก ๋ฉ์๋๊ฐ ์๋ํ์ง ์์ต๋๋ค.
https ์น ์ฌ์ดํธ์์ http ์์ฒญ์ ํ ์ ์์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ navigation.geolocation์ ์ฌ์ฉํ๋ ค๋ฉด https๋ฅผ ์ฌ์ฉํด์ผํ๋ฏ๋ก ๊ฐ์ฅ ์ข์ ๋ฐฉ๋ฒ์ darksky ์ ๊ฐ์ https API๋ฅผ ์ฌ์ฉํ๋ ๊ฒ
@raisedadead ์ด ๋ฌธ์ ๋ # 15598๋ก ์ธํด ๋ซํ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
https://cors-anywhere.herokuapp.com/
์ด๊ธฐ URL ์์ ๋ฃ์ผ๋ฉด ์ ์๊ฒ ํจ๊ณผ์ ์ด์์ต๋๋ค.
๋๋์ด :)