So I have a fetch request that returns this json:
{
"data":[
{
"latitude":44.43225,
"longitude":26.10626,
"type":"locality",
"name":"Bucharest",
"number":null,
"postal_code":null,
"street":null,
"confidence":1,
"region":"Bucharest",
"region_code":"BI",
"county":null,
"locality":"Bucharest",
"administrative_area":null,
"neighbourhood":null,
"country":"Romania",
"country_code":"ROU",
"continent":"Europe",
"label":"Bucharest, Romania"
}
]
}
In the component I want to show the latitude and longitude and I tried this way:
const conditions = (props) => {
return (
<div className={classes.Wrapper}>
{
props.error && <small className={classes.Small} > Please enter a valid city. </small>}
{
props.loading && < div className={classes.Loader} />}
{
props.responseObj.cod === 200 ?
<div className={classes.information}>
<p>{props.geoObj.data[0].longitude}</p>
<p>{props.geoObj.data[0].latitude}</p>
</div > : null
} </div>
)
}
but it doesn't work. Can you please tell me what's wrong and how should I use the objects from the JSON response.