mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-05 00:39:28 +00:00
refac, useApiClient for loader and actions
This commit is contained in:
@@ -1,31 +1,12 @@
|
||||
import defaultHeaders from '../../configuration/defaultHeaders';
|
||||
import getApiUrl from '../../configuration/getApiUrl';
|
||||
import getFetchCredentials from '../../configuration/getFetchCredentials';
|
||||
import getCookie from '../../functions/getCookie';
|
||||
import APIClient from '../../functions/APIClient';
|
||||
|
||||
export type DownloadQueueStatus = 'ignore' | 'pending' | 'priority';
|
||||
|
||||
const updateDownloadQueueStatusById = async (youtubeId: string, status: DownloadQueueStatus) => {
|
||||
const apiUrl = getApiUrl();
|
||||
const csrfCookie = getCookie('csrftoken');
|
||||
|
||||
const response = await fetch(`${apiUrl}/api/download/${youtubeId}/`, {
|
||||
return APIClient(`/api/download/${youtubeId}/`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...defaultHeaders,
|
||||
'X-CSRFToken': csrfCookie || '',
|
||||
},
|
||||
credentials: getFetchCredentials(),
|
||||
|
||||
body: JSON.stringify({
|
||||
status,
|
||||
}),
|
||||
body: { status: status },
|
||||
});
|
||||
|
||||
const downloadQueueState = await response.json();
|
||||
console.log('updateDownloadQueueStatusById', downloadQueueState);
|
||||
|
||||
return downloadQueueState;
|
||||
};
|
||||
|
||||
export default updateDownloadQueueStatusById;
|
||||
|
||||
Reference in New Issue
Block a user