@@ -14,29 +14,28 @@ exports.getBlocks = async ({ id, block, notionVersion, token }, reporter) => {
14
14
}
15
15
16
16
try {
17
- await fetch ( url , {
17
+ const result = await fetch ( url , {
18
18
headers : {
19
19
"Content-Type" : "application/json" ,
20
20
"Notion-Version" : notionVersion ,
21
21
Authorization : `Bearer ${ token } ` ,
22
22
} ,
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 ( ) )
34
24
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
39
37
} catch ( e ) {
38
+ console . log ( e )
40
39
reporter . panic ( errorMessage )
41
40
}
42
41
}
0 commit comments