File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,29 +3,11 @@ import { NotionAPI } from 'notion-client'
33import { getRevalidate } from 'utils/revalidate'
44
55const notion = new NotionAPI ( )
6-
7- const getNotionPageWithRetry = async ( id : string , retries = 3 ) => {
8- try {
9- return await notion . getPage ( id )
10- } catch ( e ) {
11- if ( retries > 0 ) {
12- const error = e as { response ?: { status ?: number ; headers ?: Headers } }
13- const status = error . response ?. status
14- if ( status === 429 ) {
15- const retryAfterHeader = error . response ?. headers ?. get ( 'retry-after' )
16- const delay = retryAfterHeader ? parseFloat ( retryAfterHeader ) * 1000 : 5000
17- await new Promise ( ( resolve ) => setTimeout ( resolve , delay ) )
18- return getNotionPageWithRetry ( id , retries - 1 )
19- }
20- }
21- throw e
22- }
23- }
24-
256export const getNotionContentProps = unstable_cache (
267 async ( id : string ) => {
278 try {
28- return await getNotionPageWithRetry ( id )
9+ const result = await notion . getPage ( id )
10+ return result
2911 } catch ( e ) {
3012 console . error ( 'Unable to get content from Notion' , e )
3113 return undefined
You can’t perform that action at this time.
0 commit comments