I'm trying to get my fullcalendar working with mongodb, but I'm stuck while trying to fetch events from database and unfortunately when it comes to pulling from mongodb, it doesn't seem to have many resources out there.
In mongodb I have events stored as:
"availability" : `[ { "start" : "09.28.2018 11:00", "end" : "09.28.2018 16:00" }, { "start" : "09.28.2018 16:00", "end" : "09.28.2018 17:00" }, { "start" : "09.30.2018 16:00", "end" : "09.30.2018 23:00" }, { "start" : "10.25.2018 10:00:00", "end" : "10.25.2018 15:00:00" } ]`
NodeJS part of the code that opens the calendar:
router.get("/calendar", function(req, res){
... })
And I have tried to make ajax call(unsuccessfully):
$.ajax({
url : '/calendar',
type : 'post',
dataType: 'json',
success: function(e){
if(e.success){
var availability = [];
$.each(e.availability,function(index,value){
availability.push({
title : value.title,
start : moment(value.start).format('YYYY-MM-DD'),
end : moment(value.end).format('YYYY-MM-DD'),
});
});
calendar.fullCalendar( 'addEventSource', availability);
}
}
});
What do I need to fix to get calendar to fetch events from database stored as is?