Skip to content

Commit

Permalink
remove whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Romarionijim committed Apr 12, 2024
1 parent d0195aa commit 584ec61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions infra/api/apiClient/ApiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export class ApiClient {
let response: APIResponse | undefined;
let responses: APIResponse[] = [];
let queryParams = options?.queryParams ? { ...options.queryParams } : {};

while (true) {
if (paginationType === PaginationType.PAGE_PAGINATION && options?.pageNumber !== undefined) {
queryParams = { ...queryParams, 'page': options.pageNumber };
Expand All @@ -113,7 +112,6 @@ export class ApiClient {
}
response = await this.makeRequest(method, url, { ...options, queryParams });
let responseObj = await response?.json();

if (!responseObj || responseObj.length === 0) {
break;
}
Expand Down Expand Up @@ -149,8 +147,12 @@ export class ApiClient {
}

public async paginateRequest<T>(method: RequestMethod, url: string, pagintionType: PaginationType, options: ApiOptionalParams<T>) {
let response = await this.paginateBy(method, url, pagintionType, options);
return response;
try {
let response = await this.paginateBy(method, url, pagintionType, options);
return response;
} catch (error) {
throw new Error(`an error occured in the paginate request function: ${error}`)
}
}

private async makeHttpRequest<T>(method: RequestMethod, url: string, options?: ApiOptionalParams<T>) {
Expand Down
2 changes: 1 addition & 1 deletion tests/api_tests/pokemon/PokemonApiTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test.describe('Pokemon API CRUD tests', async () => {
test('get all pokemon resources', { tag: ['@POKEMON_API'] }, async () => {
await test.step('get all pokemon recourses via limit and offset pagination', async () => {
let response = await pokemonApi.getAllPokemonRecourses(limit, offset)
let responseLength = response.length
let responseLength = response?.length
expect(responseLength).toBe(1302)
})
})
Expand Down

0 comments on commit 584ec61

Please sign in to comment.