From d750bca8478d2e125da0712292e4432c126196dd Mon Sep 17 00:00:00 2001 From: Gautier Darchen Date: Fri, 28 Jun 2024 15:39:45 +0200 Subject: [PATCH] fix(cache): try not to cache notion response (#10) --- src/lib/notion.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/notion.ts b/src/lib/notion.ts index deda3f3..3adb662 100644 --- a/src/lib/notion.ts +++ b/src/lib/notion.ts @@ -1,5 +1,7 @@ 'use server' +import { cache } from 'react' + import { WATCH_RESOURCES_PAGE_SIZE } from '@/constants/globals' import { Client } from '@notionhq/client' @@ -7,7 +9,7 @@ const notion = new Client({ auth: process.env.NOTION_TOKEN, }) -export const fetchWatchPages = async (cursor?: string | null) => { +export const fetchWatchPages = cache((cursor?: string | null) => { return notion.databases.query({ database_id: process.env.NOTION_DATABASE_ID!, start_cursor: cursor ?? undefined, @@ -27,4 +29,4 @@ export const fetchWatchPages = async (cursor?: string | null) => { checkbox: { equals: true }, }, }) -} +})