I am receiving a json data of single student from the server. Here i can easily get this.state.info.Firstname but i can not able to access this.state.info.Father.Firstname. How can i access this??
this is my react code:
import React from 'react';
import axios from 'axios';
class Information extends React.Component{
constructor(props){
super(props);
this.state={
info:' '
}
}
componentDidMount(){
let self = this;
axios.get('http://localhost:8080/studentById')
.then(function(data) {
//console.log(data);
self.setState({info:data.data});
});
}
render(){
return(
<div>
<pre>
<ul>
<li>{this.state.info.Firstname}</li>
<li>{this.state.info.Lastname}</li>
<li>{this.state.info.DateOfBirth}</li>
<li>{this.state.info.PlaceOfBirth}</li>
<li>{this.state.info.Age}</li>
<li>{this.state.info.Months}</li>
<li>{this.state.info.Nationality}</li>
<li>{this.state.info.MotherTongue}</li>
<li>{this.state.info.BloodGroup}</li>
<li>{this.state.info.Father.Firstname}</li>
</ul>
</pre>
</div>);
}
}
export default Information;
this is my json data:
{ _id: 5899b77c0ce1d10b723ab4ac,
Id: 92,
Firstname: 'Surya',
Age: 11,
Lastname: 'G',
DateOfBirth: '11-11-11',
PlaceOfBirth: 'Bangalore',
Months: 2,
Nationality: 'Indian',
MotherTongue: 'Kannada',
BloodGroup: 'B+ve',
ResidentialAddress: 'Vijayanagar 3rd cross, Bangalore',
EmergencyContactNumber:
{ Address: 'SIT',
PhoneNo1: 1234,
PhoneNo2: 123455,
Relationship1: 'Uncle',
Relationship2: 'Aunty' },
Mother:
{ Firstname: 'Joe',
Lastname: 'S',
Occupation: 'Business',
PlaceOfWork: 'Bangalore',
OfficialAddress: 'Jayanagar',
EmailId: '[email protected]',
PhoneNo: 12345,
MobileNo: 1234567890 },
Father:
{ Firstname: 'Chandra',
Lastname: 'S',
Occupation: 'Business',
PlaceOfWork: 'Bangalore',
OfficialAddress: 'BTM',
EmailId: '[email protected]',
PhoneNo: 12345,
MobileNo: 1234567890 } }
this.state.info.Father.Fullname??