From 37309e84351f0f93659a9ebe88f3bcec389385ce Mon Sep 17 00:00:00 2001 From: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Date: Thu, 4 Aug 2022 11:49:51 -0400 Subject: [PATCH] Properly parse list calendar call to MS Graph (#3698) --- .../app-store/office365calendar/lib/CalendarService.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/app-store/office365calendar/lib/CalendarService.ts b/packages/app-store/office365calendar/lib/CalendarService.ts index 8f5a715ce1..688f333458 100644 --- a/packages/app-store/office365calendar/lib/CalendarService.ts +++ b/packages/app-store/office365calendar/lib/CalendarService.ts @@ -158,8 +158,12 @@ export default class Office365CalendarService implements Calendar { async listCalendars(): Promise { const response = await this.fetcher(`/me/calendars`); - const responseBody = (await handleErrorsJson(response)) as { value: OfficeCalendar[] }; - return responseBody.value.map((cal) => { + let responseBody = await handleErrorsJson(response); + // If responseBody is valid then parse the JSON text + if (typeof responseBody === "string") { + responseBody = JSON.parse(responseBody) as { value: OfficeCalendar[] }; + } + return responseBody.value.map((cal: OfficeCalendar) => { const calendar: IntegrationCalendar = { externalId: cal.id ?? "No Id", integration: this.integrationName,