Shared:Utils:Axios: add generic for API types
This commit is contained in:
parent
56d9c6e774
commit
ada7d8c960
@ -33,12 +33,12 @@ export const initSSR = (headers: Record<string, string>) => {
|
||||
client.initSSR(headers);
|
||||
};
|
||||
|
||||
export const request = (
|
||||
export const request = <T>(
|
||||
options: TReqOption & AxiosRequestConfig,
|
||||
skipRedirect = false,
|
||||
isOAuth = false,
|
||||
) => {
|
||||
return client.request(options, skipRedirect, isOAuth);
|
||||
): Promise<T> | undefined => {
|
||||
return client.request<T>(options, skipRedirect, isOAuth);
|
||||
};
|
||||
|
||||
export const setWithCredentialsStatus = (state: boolean) => {
|
||||
|
@ -182,11 +182,11 @@ class AxiosClient {
|
||||
}
|
||||
};
|
||||
|
||||
request = (
|
||||
request = <T>(
|
||||
options: TReqOption & AxiosRequestConfig,
|
||||
skipRedirect = false,
|
||||
isOAuth = false,
|
||||
) => {
|
||||
): Promise<T> | undefined => {
|
||||
const onSuccess = (response: TRes) => {
|
||||
const error = this.getResponseError(response);
|
||||
|
||||
@ -295,7 +295,9 @@ class AxiosClient {
|
||||
|
||||
return Promise.reject(error);
|
||||
};
|
||||
return this.client?.(options).then(onSuccess).catch(onError);
|
||||
return this.client?.(options).then(onSuccess).catch(onError) as
|
||||
| Promise<T>
|
||||
| undefined;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -150,3 +150,10 @@ export type IClientListProps = List<IClientProps>;
|
||||
export type IClientListDTO = List<IClientResDTO>;
|
||||
|
||||
export type TConsentList = List<TConsentData>;
|
||||
|
||||
export type TGenerateDeveloperToken = {
|
||||
access_token: string;
|
||||
expires_in: number;
|
||||
scope: string;
|
||||
token_type: string;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user