"current": {
"observation_time": "03:38 PM",
"temperature": 18,
"weather_code": 113,
"weather_icons": [
"https://assets.weatherstack.com/images/wsymbols01_png_64/wsymbol_0001_sunny.png"
],
"weather_descriptions": [
"Sunny"
],
"wind_speed": 0,
"wind_degree": 345,
"wind_dir": "NNW",
"pressure": 1011,
"precip": 0,
"humidity": 58,
"cloudcover": 0,
"feelslike": 18,
"uv_index": 5,
"visibility": 16
},
"forecast": {
"2019-09-07": {
"date": "2019-09-07",
"date_epoch": 1567814400,
"astro": {
"sunrise": "06:28 AM",
"sunset": "07:19 PM",
"moonrise": "03:33 PM",
"moonset": "12:17 AM",
"moon_phase": "First Quarter",
"moon_illumination": 54
},
"mintemp": 17,
"maxtemp": 25,
"avgtemp": 21,
"totalsnow": 0,
"sunhour": 10.3,
"uv_index": 5,
<!-- end snippet -->
I want to display sunrise and sunset and also the sunhour under the forecast object, So far i have tried {forecast["2019-09-07"].astro.sunrise} but it's still not working, Please what how else do i call it from the api?? Thanks in advance.
CodePudding user response:
use ramda path for it https://ramdajs.com/docs/#path
path(['2019-09-07', 'astro', 'sunrise'])(forecast)
CodePudding user response:
So i did {country.forecast?.["2022-11-11"]?.astro?.sunrise} and it worked, Thanks anyway.