Hey guys! I want to get all my meetings from Google calendar API from 2022. I want to fetch them wee

Hey guys!
I want to get all my meetings from Google calendar API from 2022. I want to fetch them week by week. For example like this:

for (const { weekStart, weekEnd } of weeklyIntervals) {
      const events = await step.do(
        `fetchMeetings for ${weekStart} - ${weekEnd}`,
        { retries: { limit: 3, delay: 2000 } },
        async () => {
          const response = await fetch(
            `https://www.googleapis.com/calendar/v3/calendars/primary/events?timeMin=${weekStart}&timeMax=${weekEnd}&orderBy=startTime&singleEvents=true`,
            {
              headers: { Authorization: `Bearer ${accessToken}` },
            }
          );

          if (!response.ok) throw new Error("Failed to fetch events");
          const data = await response.json();
          return data.items.map((event: { summary: string }) => event.summary);
        }
      );

      // Log summaries for this week
      events.forEach((summary: string, index: number) =>
        console.log(`Event ${index + 1} on week ${weekStart} - ${weekEnd}: ${summary}`)
      );
    }


Will this solution work? Should I include the loop inside the step? (I am in free tier) Does the paid plan have unlimited steps?
Was this page helpful?