Migrated ImageDownloader from axios to fetch

This commit is contained in:
Alejandro Celaya
2022-11-15 11:41:05 +01:00
parent a88ebc26a9
commit 34aa156d5f
9 changed files with 21 additions and 31 deletions

View File

@@ -20,7 +20,7 @@ import {
import { orderToString } from '../../utils/helpers/ordering';
import { isRegularNotFound, parseApiError } from '../utils';
import { stringifyQuery } from '../../utils/helpers/query';
import { Fetch } from '../../utils/types';
import { JsonFetch } from '../../utils/types';
const buildShlinkBaseUrl = (url: string, version: 2 | 3) => `${url}/rest/v${version}`;
const rejectNilProps = reject(isNil);
@@ -34,7 +34,7 @@ export class ShlinkApiClient {
private apiVersion: 2 | 3;
public constructor(
private readonly fetch: Fetch,
private readonly fetch: JsonFetch,
private readonly baseUrl: string,
private readonly apiKey: string,
) {

View File

@@ -1,7 +1,7 @@
import { hasServerData, ServerWithId } from '../../servers/data';
import { GetState } from '../../container/types';
import { ShlinkApiClient } from './ShlinkApiClient';
import { Fetch } from '../../utils/types';
import { JsonFetch } from '../../utils/types';
const apiClients: Record<string, ShlinkApiClient> = {};
@@ -16,7 +16,7 @@ const getSelectedServerFromState = (getState: GetState): ServerWithId => {
return selectedServer;
};
export const buildShlinkApiClient = (fetch: Fetch) => (getStateOrSelectedServer: GetState | ServerWithId) => {
export const buildShlinkApiClient = (fetch: JsonFetch) => (getStateOrSelectedServer: GetState | ServerWithId) => {
const { url, apiKey } = isGetState(getStateOrSelectedServer)
? getSelectedServerFromState(getStateOrSelectedServer)
: getStateOrSelectedServer;