File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -25,21 +25,18 @@ export class Qiita extends Gateway {
25
25
* @param initialUrl 最初にリクエストするURL
26
26
* @param params リクエストのオプション
27
27
*/
28
- protected async * paginationGenerator < T extends any [ ] > ( initialUrl : string , params ?: options . PaginationOptions ) {
29
- let next : string | null = initialUrl + ( params ? '?' + querystring . stringify ( params ) : '' ) ;
28
+ protected async * paginationGenerator < T extends any [ ] > ( url : string , params ?: options . PaginationOptions ) {
29
+ const initialUrl = url + ( params ? '?' + querystring . stringify ( params ) : '' ) ;
30
+ let next : string | null = initialUrl ;
30
31
31
- while ( true ) {
32
+ while ( next ) {
32
33
const response = await this . get < T > ( next ) ;
33
- const result : T | 'reset' = yield response . data ;
34
+ const result = yield response . data as T | 'reset' ;
34
35
35
36
if ( result === 'reset' ) {
36
37
next = initialUrl ;
37
- }
38
-
39
- next = getNextUrl ( response . headers ) ;
40
-
41
- if ( ! next ) {
42
- break ;
38
+ } else {
39
+ next = getNextUrl ( response . headers ) ;
43
40
}
44
41
}
45
42
}
You can’t perform that action at this time.
0 commit comments