Skip to content

Commit

Permalink
fix(cache): try not to cache notion response (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
gdarchen authored Jun 28, 2024
1 parent 73fa5e3 commit d750bca
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/notion.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
'use server'

import { cache } from 'react'

import { WATCH_RESOURCES_PAGE_SIZE } from '@/constants/globals'
import { Client } from '@notionhq/client'

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,
Expand All @@ -27,4 +29,4 @@ export const fetchWatchPages = async (cursor?: string | null) => {
checkbox: { equals: true },
},
})
}
})

0 comments on commit d750bca

Please sign in to comment.