Skip to content

Commit

Permalink
refactor: schedules client
Browse files Browse the repository at this point in the history
  • Loading branch information
tutkli committed Feb 6, 2024
1 parent 010deb4 commit e9ede87
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/clients/schedules.client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { AxiosError } from 'axios';
import { CacheAxiosResponse } from 'axios-cache-interceptor';
import { SchedulesEndpoints } from '../constants/endpoints/schedules.endpoints';
import { Anime, JikanResponse, SchedulesParams } from '../models';
import { BaseClient } from './base.client';
Expand All @@ -20,14 +18,10 @@ export class SchedulesClient extends BaseClient {
public async getSchedules(
searchParams?: Partial<SchedulesParams>
): Promise<JikanResponse<Anime[]>> {
return new Promise<JikanResponse<Anime[]>>((resolve, reject) => {
const endpoint = `${SchedulesEndpoints.Schedules}`;
this.api
.get<JikanResponse<Anime[]>>(endpoint, { params: searchParams })
.then((response: CacheAxiosResponse<JikanResponse<Anime[]>>) =>
resolve(response.data)
)
.catch((error: AxiosError<string>) => reject(error));
});
return this.getResource<JikanResponse<Anime[]>>(
SchedulesEndpoints.Schedules,
{},
searchParams
);
}
}

0 comments on commit e9ede87

Please sign in to comment.