@@ -33,7 +33,7 @@ export abstract class BaseApi {
33
33
/**
34
34
* CONSTRUCTOR
35
35
*/
36
- protected constructor ( name : string , urlBase : string , minimumDelay : number = 1000 , timeout : number = 10000 ) {
36
+ protected constructor ( name : string , urlBase : string , minimumDelay : number = 1000 , timeout : number = 10000 ) {
37
37
this . name = name
38
38
this . urlBase = urlBase
39
39
this . timeout = timeout
@@ -45,7 +45,7 @@ export abstract class BaseApi {
45
45
} )
46
46
}
47
47
48
- cleanUrlParamString ( word : string ) : string {
48
+ cleanUrlParamString ( word : string ) : string {
49
49
return word . replace ( / \s / g, '%20' ) . replace ( / a n d / gi, '%26' )
50
50
}
51
51
@@ -54,7 +54,7 @@ export abstract class BaseApi {
54
54
*/
55
55
_axiosInstance : AxiosInstance
56
56
57
- protected get client ( ) : AxiosInstance {
57
+ protected get client ( ) : AxiosInstance {
58
58
return this . _axiosInstance
59
59
}
60
60
@@ -67,28 +67,28 @@ export abstract class BaseApi {
67
67
* Supported methods
68
68
* - GET, POST, PATCH, DELETE
69
69
*/
70
- protected async httpGet ( url : string , headers : AxiosRequestConfig [ 'headers' ] = { } ) : Promise < ApiResponse < unknown > > {
70
+ protected async httpGet ( url : string , headers : AxiosRequestConfig [ 'headers' ] = { } ) : Promise < ApiResponse < unknown > > {
71
71
this . loading = true
72
72
const response = await this . catchDuplicates ( async ( ) => await this . client . get ( url , { headers } ) , url )
73
73
this . loading = false
74
74
return response
75
75
}
76
76
77
- protected async httpPost ( url : string , body : object , headers : AxiosRequestConfig [ 'headers' ] = { } ) : Promise < ApiResponse < unknown > > {
77
+ protected async httpPost ( url : string , body : object , headers : AxiosRequestConfig [ 'headers' ] = { } ) : Promise < ApiResponse < unknown > > {
78
78
this . loading = true
79
79
const response = await this . catchDuplicates ( async ( ) => await this . client . post ( url , body , { headers } ) , url )
80
80
this . loading = false
81
81
return response
82
82
}
83
83
84
- protected async httpPatch ( url : string , body : object , headers : AxiosRequestConfig [ 'headers' ] = { } ) : Promise < ApiResponse < unknown > > {
84
+ protected async httpPatch ( url : string , body : object , headers : AxiosRequestConfig [ 'headers' ] = { } ) : Promise < ApiResponse < unknown > > {
85
85
this . loading = true
86
86
const response = await this . catchDuplicates ( async ( ) => await this . client . patch ( url , body , { headers } ) , url )
87
87
this . loading = false
88
88
return response
89
89
}
90
90
91
- protected async httpDelete ( url : string , headers : AxiosRequestConfig [ 'headers' ] = { } ) : Promise < ApiResponse < unknown > > {
91
+ protected async httpDelete ( url : string , headers : AxiosRequestConfig [ 'headers' ] = { } ) : Promise < ApiResponse < unknown > > {
92
92
this . loading = true
93
93
const response = await this . catchDuplicates ( async ( ) => await this . client . delete ( url , { headers } ) , url )
94
94
this . loading = false
@@ -135,7 +135,7 @@ export abstract class BaseApi {
135
135
return response
136
136
} catch ( error ) {
137
137
console . error ( `Error in ${ this . name } for URL ${ urlToCall } :` , error )
138
- return new ApiResponseError < T > ( { } as AxiosResponse )
138
+ return new ApiResponseError < T > ( { } as const as AxiosResponse < T > )
139
139
}
140
140
}
141
- }
141
+ }
0 commit comments