Skip to content

Commit 041b264

Browse files
committed
初期URLのリセットの挙動を修正
1 parent 548f9c6 commit 041b264

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/client/Qiita.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,18 @@ export class Qiita extends Gateway {
2525
* @param initialUrl 最初にリクエストするURL
2626
* @param params リクエストのオプション
2727
*/
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;
3031

31-
while (true) {
32+
while (next) {
3233
const response = await this.get<T>(next);
33-
const result: T | 'reset' = yield response.data;
34+
const result = yield response.data as T | 'reset';
3435

3536
if (result === 'reset') {
3637
next = initialUrl;
37-
}
38-
39-
next = getNextUrl(response.headers);
40-
41-
if (!next) {
42-
break;
38+
} else {
39+
next = getNextUrl(response.headers);
4340
}
4441
}
4542
}

0 commit comments

Comments
 (0)