@@ -14,29 +14,28 @@ exports.getBlocks = async ({ id, block, notionVersion, token }, reporter) => {
1414 }
1515
1616 try {
17- await fetch ( url , {
17+ const result = await fetch ( url , {
1818 headers : {
1919 "Content-Type" : "application/json" ,
2020 "Notion-Version" : notionVersion ,
2121 Authorization : `Bearer ${ token } ` ,
2222 } ,
23- } )
24- . then ( ( res ) => res . json ( ) )
25- . then ( async ( res ) => {
26- for ( let childBlock of res . results ) {
27- if ( childBlock . has_children ) {
28- childBlock [ childBlock . type ] . children = await this . getBlocks (
29- { id : block . id , block : childBlock , notionVersion, token } ,
30- reporter ,
31- )
32- }
33- }
23+ } ) . then ( ( res ) => res . json ( ) )
3424
35- blockContent = blockContent . concat ( res . results )
36- startCursor = res . next_cursor
37- hasMore = res . has_more
38- } )
25+ for ( let childBlock of result . results ) {
26+ if ( childBlock . has_children ) {
27+ childBlock . children = await this . getBlocks (
28+ { id : childBlock . id , block : childBlock , notionVersion, token } ,
29+ reporter ,
30+ )
31+ }
32+ }
33+
34+ blockContent = blockContent . concat ( result . results )
35+ startCursor = result . next_cursor
36+ hasMore = result . has_more
3937 } catch ( e ) {
38+ console . log ( e )
4039 reporter . panic ( errorMessage )
4140 }
4241 }
0 commit comments