diff --git a/packages/nocodb/src/services/datas.service.ts b/packages/nocodb/src/services/datas.service.ts index 533adca734..07250afc22 100644 --- a/packages/nocodb/src/services/datas.service.ts +++ b/packages/nocodb/src/services/datas.service.ts @@ -221,9 +221,9 @@ export class DatasService { if (view.type !== ViewTypes.CALENDAR) NcError.badRequest('View is not a calendar view'); - const { ranges } = await CalendarRange.read(view.id); + const calendarRange = await CalendarRange.read(view.id); - if (!ranges.length) NcError.badRequest('No ranges found'); + if (!calendarRange?.ranges?.length) NcError.badRequest('No ranges found'); const model = await Model.getByIdOrName({ id: view.fk_model_id, @@ -239,7 +239,7 @@ export class DatasService { const dates: Array = []; - ranges.forEach((range: any) => { + calendarRange.ranges.forEach((range: any) => { data.list.forEach((date) => { const from = date[ diff --git a/packages/nocodb/src/services/public-datas.service.ts b/packages/nocodb/src/services/public-datas.service.ts index 677c91084f..bf185627d0 100644 --- a/packages/nocodb/src/services/public-datas.service.ts +++ b/packages/nocodb/src/services/public-datas.service.ts @@ -117,7 +117,7 @@ export class PublicDatasService { const calendarRange = await CalendarRange.read(view.id); - if (!calendarRange || !calendarRange.ranges.length) + if (!calendarRange?.ranges?.length) NcError.notFound('Calendar ranges are required in a calendar view'); const model = await Model.getByIdOrName({