Initial commit: Tapalka monorepo (bot, front, strapi)
This commit is contained in:
38
CMyTapper/robucks-front/api/tasks.api.ts
Normal file
38
CMyTapper/robucks-front/api/tasks.api.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { AxiosInstance } from 'axios';
|
||||
import { HttpInstanceFactory } from '@/utils/HttpInstanceFactory';
|
||||
|
||||
export interface ITask {
|
||||
id: number;
|
||||
attributes: {
|
||||
title: string;
|
||||
link: string;
|
||||
prize: number;
|
||||
icon: {
|
||||
data: {
|
||||
id: number;
|
||||
attributes: {
|
||||
url: string;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export class TasksApi {
|
||||
private static instance: TasksApi | null = null;
|
||||
private httpInstance: AxiosInstance;
|
||||
|
||||
private constructor(token?: string) {
|
||||
this.httpInstance = HttpInstanceFactory.getAuthorizedInstance(token);
|
||||
}
|
||||
|
||||
public static getInstance(token?: string): TasksApi {
|
||||
if (this.instance) return this.instance;
|
||||
this.instance = new TasksApi(token);
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
async getAllTasks(): Promise<ITask[]> {
|
||||
return (await this.httpInstance.get<{ data: ITask[] }>(`/tasks?populate=*`)).data.data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user