2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +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:
Taemin Shin
2020-10-20 15:04:44 +09:00
committed by GitHub
parent 9a78465a92
commit 3a8b87d48a
2 changed files with 9 additions and 1 deletions
Vendored
+1 -1
View File
@@ -62,7 +62,7 @@ export interface AxiosRequestConfig {
onUploadProgress?: (progressEvent: any) => void;
onDownloadProgress?: (progressEvent: any) => void;
maxContentLength?: number;
validateStatus?: ((status: number) => boolean | null);
validateStatus?: ((status: number) => boolean) | null;
maxBodyLength?: number;
maxRedirects?: number;
socketPath?: string | null;
+8
View File
@@ -44,6 +44,14 @@ const config: AxiosRequestConfig = {
cancelToken: new axios.CancelToken((cancel: Canceler) => {})
};
const nullValidateStatusConfig: AxiosRequestConfig = {
validateStatus: null
};
const undefinedValidateStatusConfig: AxiosRequestConfig = {
validateStatus: undefined
};
const handleResponse = (response: AxiosResponse) => {
console.log(response.data);
console.log(response.status);