fix(backend-git-gateway): re-write GitHub pagination links (#3135)

This commit is contained in:
Erez Rokah
2020-01-24 04:14:33 +02:00
committed by Shawn Erquhart
parent 48afa8dfe4
commit 834f6b9e45
5 changed files with 30 additions and 4 deletions

View File

@ -264,10 +264,19 @@ export default class API {
.catch(error => this.handleRequestError(error, responseStatus));
}
nextUrlProcessor() {
return (url: string) => url;
}
async requestAllPages<T>(url: string, options: Options = {}) {
const headers = await this.requestHeaders(options.headers || {});
const processedURL = this.urlFor(url, options);
const allResponses = await getAllResponses(processedURL, { ...options, headers });
const allResponses = await getAllResponses(
processedURL,
{ ...options, headers },
'next',
this.nextUrlProcessor(),
);
const pages: T[][] = await Promise.all(
allResponses.map((res: Response) => this.parseResponse(res)),
);