0

I am using react big calendar and I am using the start days and end days of the week for my api call here's the function I am calling to get events

getEvents(calendarId,firstday,lastDay);

this function creates the api url to hit using the calendar id and the dates for first day and last day.

so, if the calendar shows the week as 20th august - 27 august then first day is 20-08-2017 and last day is 27-08-2017 and my api url becomes

calendar/events/?start="20-08-2017"&end="27-08-2017"

for next week i.e 28-08-2017 to 3-08-2017 I want to get dates automatically from the calendar so I can use it in my api call?

the problem is that I am quite new to react-big-calendar and I dont know how to get the dates from there. I'd really appreciate it if you could provide some suggestions or advice or even point me where to look. I have been through the documentation but couldnt get what I want.

EDIT: I am using onNavigate as shown below to call the function that makes the api call

onNavigate={() => {
 actions.calendar.getEvents(this.props.params.calendarId, firstday, lastday);

              }}
faraz
  • 2,603
  • 12
  • 39
  • 61
  • Basically I want to get the current view information from the calendar view ie. the start date (of the week) and the end date. – faraz Aug 23 '17 at 12:22

1 Answers1

0

Try to change your callback to accept the current start date of your calendar:

onNavigate={(date) => ...}

and calculate the requered date range for your API call e.g. using moment JS lib.

Erich Schreiner
  • 2,038
  • 1
  • 14
  • 24