I am trying to parse JSON response fetched from an API in index.html and sending it to a component Card.js as props and trying to render it, but it turns out that I can just access it only to a certain extent. I can get the console log of the response but cannot render it. I am a beginner in reactjs. Any help will be appreciated.
card.js
import { render } from 'react-dom';
import '../css/styles.css'
const Card = function(props){
console.log("props", props.props.coord)
return(
<div>
<h1>Weather Information</h1>
<div>{props.props.coord.lon}</div>
{/* <ul>
<li>Longitude:{t['lon']}</li>
</ul> */}
</div>
// <div class = "card-complete">{cardval}</div>
)
}
export default Card;
index.js
import React,{Component} from 'react';
import ReactDOM from 'react-dom';
import JSON from './weatherdata.json'
import Card from './components/card'
import App from './components/App'
class WeatherApp extends Component{
state = {
apidata : []
}
componentDidMount(){
fetch("https://fcc-weather-api.glitch.me/api/current?lat=35&lon=139")
.then(data => data.json())
.then(data => this.setState({apidata: data}))
.catch(console.log)
}
render(){
return(
<div>
<App/>
<Card props={this.state.apidata}/>
</div>
)
}
}
ReactDOM.render(<WeatherApp />, document.getElementById('root'));
I cannot access the 'lon' and 'lat' parameters. TypeError: Cannot read property 'lon' of undefined.
Edit:
If I use props.props.coord.lon, I get Cannot read property 'lon' of undefined and if I use just props.props.coord in div it shows that it is not a valid react child, object with keys lat and lon found.

