I have this array:
{
"firstname": "Jessica",
"lastname": "Wood",
"favorite": {
"movie": Flint Town,
"drink": Sprite
}
}
I am trying to get drink and i got Objects are not valid as a React child found: object with keys.
How can i fix that?
My react component:
import React, { Component } from 'react';
import axios from 'axios';
class Home extends Component {
state = {
info: []
}
componentDidMount() {
axios.get('http://localhost:9000/api')
.then(res => {
const info = res.data;
this.setState({ info });
})
}
render() {
return (
<ul>
<li>{this.state.info.favorite.drink}</li>
</ul>
)
}
}
export default Home;
infoanArrayor anObject