Notice
Recent Posts
Recent Comments
Link
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
Archives
Today
Total
관리 메뉴

차근차근

[React Native] Weather App(2) 본문

대학교/FE

[React Native] Weather App(2)

SWKo 2020. 2. 28. 20:50

0. Getting the Weather

  • 위치 정보 확인에서 받아온 위도, 경도를 토대로 api를 부른다.
  • isLoaded = true를 쓰는 대신에 새로운 _getWeather이라는 새로운 함수를 만들었다.경도, 위도, 2개의 attrubutes를 얻게 되면 웹사이트에서 제공하는 api key를 사용한다.
  • open weather map >> current weather data >> geo coordinates 를 그들의 서버에 보내면 날씨정보를 받아올 수 있는 것이다.
  • 그것을 보낼 때마다 response를 json으로 하고 그 json을 console.log 할것이다.

https://openweathermap.org/

 

Сurrent weather and forecast - OpenWeatherMap

Dashboard and Agro API We provide satellite imagery, weather data and other agricultural services that are based on geodata. By using Agro API , you can easily power your solution based on this information. Dashboard is a visual service where you can easy

openweathermap.org

  • API를 받아온 후 작성한 코드

  • console.log(json)의 결과

  • api에서 받아온 데이터는 json object가 있는데 그 main안에 온도를 가져오고, 그 다음 weather array의 첫번째 element를 가져온다.

  • 휴대폰에서 폰을 흔든 후 개발자 모드에서 Remote Debugging을 클릭하면 웹브라우저로 다음과 같이 디버깅할 수 있다.

  • 위 정보를 이제 적용시키기만 하면 된다.

1. Hooking the Weather: Component to the weather data

  • 코드는 깃헙에 올려두었다.

https://github.com/KoSangWon/ReactNative_weather_app

 

KoSangWon/ReactNative_weather_app

Weather App React-Native. Contribute to KoSangWon/ReactNative_weather_app development by creating an account on GitHub.

github.com

 

'대학교 > FE' 카테고리의 다른 글

[React-Native] (1) React Native란 무엇인가?  (0) 2020.03.03
[React-Native] Redux  (0) 2020.03.02
[React Native] Weather App(1)  (0) 2020.02.28
[React Native] Flexbox  (0) 2020.02.28
[React Native] React Native & Expo  (0) 2020.02.27
Comments