The json data is in the below pattern. And the Json data is coming from backend and getting through api and storing in a state variable.
{ "message": "user created successfully", "status": "success", "student": { "class": "10", "email": "[email protected]", "name": "User", "password": "user", "phone_number": "some phone number", "school": "1", "section": "a" } } I have stored the data which is returned through api in a state variable.
constructor(){ super(); this.state = { jsonData: '' } } And tried accessing using below fashion.
this.state.jsonData.status but not able to access. How can I access the status value in react?
componentDidMountand in the response you need to set the state value asthis.setState({jsonData: result})like this