как мне заполнить большой календарь данными из API Ax ios, создать массив ............................. .................................................. .....
class Calendar extends Component {
constructor() {
super();
this.state = {
events: [],
info: false,
title: null,
startDate: null,
endDay: null,
startTime: null,
endTime: null,
description: null
};
this.toggle = this.toggle.bind(this);
this.toggleInfo = this.toggleInfo.bind(this);
}
handleChange = e => {
this.setState({ [e.target.name]: e.target.value });
};
использовать Ax ios для получения запроса от API ......................
loadCalendar() {
axios
.get(api + "api/calendar", {
headers: {
"Content-type": "application/json",
Authorization: reqtoken
}
})
.then(json => {
json.data.data.data.map(data =>
this.setState(
events({
title: data.title,
start: data.startDate,
end: data.endDate
})
)
);
})
.catch(erros => {
console.log(erros);
});
}
componentDidMount() {
this.loadCalendar();
}
reder retorn html с данными api ................................... .........................
render() {
return (
<CardBody style={{ height: "40rem" }}>
<BigCalendar
className="d-sm-down-none"
style={{ height: "-webkit-fill-available" }}
{...this.props}
events={events}
views={["month", "week", "day"]}
step={30}
defaultDate={new Date(currYear, currMonth, 1)}
defaultView="month"
toolbar={true}
localizer={localizer}
/>
<BigCalendar
className="d-md-none"
{...this.props}
events={events}
views={["day"]}
step={30}
defaultDate={new Date(currYear, currMonth, 1)}
defaultView="day"
toolbar={true}
localizer={localizer}
/>
</CardBody>
)