i am trying to show my own data in calendar events via fetch. This is my code:
<script>
export default {
data() {
return {
fechadatos: []
}
},
async created() {
// GET request using fetch with async/await
const response = await fetch("http://127.0.0.1:8000/apifechaClase/");
const data = await response.json();
this.fechadatos = data[0]
},
mounted() {
document.addEventListener('DOMContentLoaded', function () {
const calendarEl = document.getElementById('calendar');
const calendar = new FullCalendar.Calendar(calendarEl, {
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
},
initialView: 'dayGridMonth',
initialDate: '2020-09-12',
navLinks: true, // can click day/week names to navigate views
selectable: true,
nowIndicator: true,
dayMaxEvents: true, // allow "more" link when too many events
editable: true,
businessHours: true,
events: [{
title: 'All Day Event',
start: '2020-09-01',
}, {
title: 'Long Event',
start: '2020-09-07',
end: '2020-09-10'
}]
});
calendar.render();
});
}
}
</script>
The problem is that i don't know how to put my info in to calendar events:
events: [{
title: var.from.api,
start: var.from.api,
}, {
title: var.from.api,
start: var.from.api,
end: var.from.api
}]
something like that (?) i don't know how to get the api info to show it.