I will explain my problem to you today: the following code works fine, I get my database, then I use a map function, so everything is fine. My question and the next, I get a table in it I have an object that contains an array. This table has the following form:
[{"title":"Lagunitas IPA (Demi-Pinte","quantity":2}]
and it is possible to recover one of the two pieces of data because when I map over the array I get all of it.
Do you have an idea of how to fix this?
import React, { Component } from 'react';
import { CardText, Col } from 'reactstrap';
import axios from 'axios'
const entrypoint = process.env.REACT_APP_API_ENTRYPOINT+'/api';
class AdminPage extends Component {
constructor(props) {
super(props);
this.state = {
data: [],
},
};
}
getRandom = async () => {
const res = await axios.get(
entrypoint + "/alluserpls"
)
this.setState({ data: res.data })
}
componentDidMount() {
this.getRandom()
}
render() {
let datas = this.state.data.map(datass => {
return (
<div >
<Col sm="12" key={datass.id}">
<CardText> Commande{datass.items}</CardText>
</Col>
</div>
)
})
return (
<div>
{datas}
</div>
)
}
}
export default AdminPage