mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Fixing an issue that type 'null' and 'undefined' is not assignable to validateStatus when typescript strict option is enabled (#3200)
This commit is contained in:
Vendored
+1
-1
@@ -62,7 +62,7 @@ export interface AxiosRequestConfig {
|
|||||||
onUploadProgress?: (progressEvent: any) => void;
|
onUploadProgress?: (progressEvent: any) => void;
|
||||||
onDownloadProgress?: (progressEvent: any) => void;
|
onDownloadProgress?: (progressEvent: any) => void;
|
||||||
maxContentLength?: number;
|
maxContentLength?: number;
|
||||||
validateStatus?: ((status: number) => boolean | null);
|
validateStatus?: ((status: number) => boolean) | null;
|
||||||
maxBodyLength?: number;
|
maxBodyLength?: number;
|
||||||
maxRedirects?: number;
|
maxRedirects?: number;
|
||||||
socketPath?: string | null;
|
socketPath?: string | null;
|
||||||
|
|||||||
@@ -44,6 +44,14 @@ const config: AxiosRequestConfig = {
|
|||||||
cancelToken: new axios.CancelToken((cancel: Canceler) => {})
|
cancelToken: new axios.CancelToken((cancel: Canceler) => {})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const nullValidateStatusConfig: AxiosRequestConfig = {
|
||||||
|
validateStatus: null
|
||||||
|
};
|
||||||
|
|
||||||
|
const undefinedValidateStatusConfig: AxiosRequestConfig = {
|
||||||
|
validateStatus: undefined
|
||||||
|
};
|
||||||
|
|
||||||
const handleResponse = (response: AxiosResponse) => {
|
const handleResponse = (response: AxiosResponse) => {
|
||||||
console.log(response.data);
|
console.log(response.data);
|
||||||
console.log(response.status);
|
console.log(response.status);
|
||||||
|
|||||||
Reference in New Issue
Block a user