mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-05 03:59:24 +00:00
refac, useApiClient for loader and actions
This commit is contained in:
@@ -1,30 +1,10 @@
|
||||
import defaultHeaders from '../../configuration/defaultHeaders';
|
||||
import getApiUrl from '../../configuration/getApiUrl';
|
||||
import getFetchCredentials from '../../configuration/getFetchCredentials';
|
||||
import getCookie from '../../functions/getCookie';
|
||||
import isDevEnvironment from '../../functions/isDevEnvironment';
|
||||
import APIClient from '../../functions/APIClient';
|
||||
import { TaskScheduleNameType } from './createTaskSchedule';
|
||||
|
||||
const deleteTaskSchedule = async (taskName: TaskScheduleNameType) => {
|
||||
const apiUrl = getApiUrl();
|
||||
const csrfCookie = getCookie('csrftoken');
|
||||
|
||||
const response = await fetch(`${apiUrl}/api/task/schedule/${taskName}/`, {
|
||||
return APIClient(`/api/task/schedule/${taskName}/`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
...defaultHeaders,
|
||||
'X-CSRFToken': csrfCookie || '',
|
||||
},
|
||||
credentials: getFetchCredentials(),
|
||||
});
|
||||
|
||||
const scheduledTask = await response.json();
|
||||
|
||||
if (isDevEnvironment()) {
|
||||
console.log('deleteTaskSchedule', scheduledTask);
|
||||
}
|
||||
|
||||
return scheduledTask;
|
||||
};
|
||||
|
||||
export default deleteTaskSchedule;
|
||||
|
||||
Reference in New Issue
Block a user