type fixes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import axios, { AxiosInstance } from "axios";
|
||||
import type { AxiosResponse } from "axios";
|
||||
import { createApiClient } from "../../react-auth";
|
||||
|
||||
/**
|
||||
@@ -30,25 +31,25 @@ function withParamsSerializer(instance: AxiosInstance): AxiosInstance {
|
||||
}
|
||||
|
||||
export const api = {
|
||||
get: (...args: Parameters<AxiosInstance["get"]>) => {
|
||||
get: <T = any, R = AxiosResponse<T>>(url: string, config?: Parameters<AxiosInstance["get"]>[1]) => {
|
||||
if (!_api) throw new Error("API client not initialized");
|
||||
return _api.get(...args);
|
||||
return _api.get<T, R>(url, config);
|
||||
},
|
||||
post: (...args: Parameters<AxiosInstance["post"]>) => {
|
||||
post: <T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: Parameters<AxiosInstance["post"]>[2]) => {
|
||||
if (!_api) throw new Error("API client not initialized");
|
||||
return _api.post(...args);
|
||||
return _api.post<T, R>(url, data, config);
|
||||
},
|
||||
put: (...args: Parameters<AxiosInstance["put"]>) => {
|
||||
put: <T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: Parameters<AxiosInstance["put"]>[2]) => {
|
||||
if (!_api) throw new Error("API client not initialized");
|
||||
return _api.put(...args);
|
||||
return _api.put<T, R>(url, data, config);
|
||||
},
|
||||
delete: (...args: Parameters<AxiosInstance["delete"]>) => {
|
||||
delete: <T = any, R = AxiosResponse<T>>(url: string, config?: Parameters<AxiosInstance["delete"]>[1]) => {
|
||||
if (!_api) throw new Error("API client not initialized");
|
||||
return _api.delete(...args);
|
||||
return _api.delete<T, R>(url, config);
|
||||
},
|
||||
patch: (...args: Parameters<AxiosInstance["patch"]>) => {
|
||||
patch: <T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: Parameters<AxiosInstance["patch"]>[2]) => {
|
||||
if (!_api) throw new Error("API client not initialized");
|
||||
return _api.patch(...args);
|
||||
return _api.patch<T, R>(url, data, config);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user