mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-08 09:29:24 +00:00
Refac APIClient to return data, error and status as object
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import APIClient from '../../functions/APIClient';
|
||||
import { CookieStateType } from '../loader/loadCookie';
|
||||
|
||||
const deleteCookie = async (): Promise<CookieStateType> => {
|
||||
return APIClient('/api/appsettings/cookie/', {
|
||||
const deleteCookie = async () => {
|
||||
return APIClient<CookieStateType>('/api/appsettings/cookie/', {
|
||||
method: 'DELETE',
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import APIClient from '../../functions/APIClient';
|
||||
import { CookieStateType } from '../loader/loadCookie';
|
||||
|
||||
const updateCookie = async (cookie: string): Promise<CookieStateType> => {
|
||||
return APIClient('/api/appsettings/cookie/', {
|
||||
const updateCookie = async (cookie: string) => {
|
||||
return APIClient<CookieStateType>('/api/appsettings/cookie/', {
|
||||
method: 'PUT',
|
||||
body: { cookie },
|
||||
});
|
||||
|
||||
@@ -25,8 +25,8 @@ export type UserConfigType = {
|
||||
show_help_text: boolean;
|
||||
};
|
||||
|
||||
const updateUserConfig = async (config: Partial<UserConfigType>): Promise<UserConfigType> => {
|
||||
return APIClient('/api/user/me/', {
|
||||
const updateUserConfig = async (config: Partial<UserConfigType>) => {
|
||||
return APIClient<UserConfigType>('/api/user/me/', {
|
||||
method: 'POST',
|
||||
body: config,
|
||||
});
|
||||
|
||||
@@ -14,11 +14,8 @@ type VideoProgressProp = {
|
||||
currentProgress: number;
|
||||
};
|
||||
|
||||
const updateVideoProgressById = async ({
|
||||
youtubeId,
|
||||
currentProgress,
|
||||
}: VideoProgressProp): Promise<VideoProgressResponseType> => {
|
||||
return APIClient(`/api/video/${youtubeId}/progress/`, {
|
||||
const updateVideoProgressById = async ({ youtubeId, currentProgress }: VideoProgressProp) => {
|
||||
return APIClient<VideoProgressResponseType>(`/api/video/${youtubeId}/progress/`, {
|
||||
method: 'POST',
|
||||
body: { position: currentProgress },
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import APIClient from '../../functions/APIClient';
|
||||
import { CookieStateType } from '../loader/loadCookie';
|
||||
|
||||
const validateCookie = async (): Promise<CookieStateType> => {
|
||||
return APIClient('/api/appsettings/cookie/', {
|
||||
const validateCookie = async () => {
|
||||
return APIClient<CookieStateType>('/api/appsettings/cookie/', {
|
||||
method: 'POST',
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user