constructor(props) {
super(props);
this.state = {
message: []
};
}
async getData() {
await axios.get("https:...")
.then((response) => {
console.log((response));
console.log(typeof(response)); // object
const convertString = JSON.parse(response.data.body);
this.setState({message: convertString});
console.log(convertString));
})
}
componentDidMount() {
this.getData();
}
render() {
const obj = (this.state.message);
console.log(obj);
return(
<div>
{this.state.message}
</div>
)
I get the error: "Error: Objects are not valid as a React child (found: object with keys {Items, Count, ScannedCount}). If you meant to render a collection of children, use an array instead."
console.log(convertString) gives me this:
Items: Array(4)
0: {key1: "value", key2: "value"}
1: {key1: "value", key2: "value"}
2: {key1: "value", key2: "value"}
3: {key1: "value", key2: "value"}
How should I pass the data via this.setState() if I want to render the array in a table format?