import axios , { AxiosInstance , AxiosRequestConfig } from "axios" ; const has = require ( "lodash/has" ) ; const CancelToken = axios . CancelToken ; const instance = axios . create ( { timeout : 500000 , headers : { "Cache-Control" : "no-cache" , Pragma : "no-cache" , Expires : "-1" , } , withCredentials : true } ) ; export let uploadApi = axios . create ( { timeout : 500000 , headers : { "Cache-Control" : "no-cache" , Pragma : "no-cache" , Expires : "-1" , } } ) ; function success ( resp ) { if ( resp . status === 200 ) { if ( resp . data . errorCode ) { return Promise . reject ( new Error ( ) ) ; } else { return resp . data ; } } } function error ( error ) { if ( error . response && error . response . status === 401 ) { } else if ( error . response && error . response . status === 403 ) { } else { } return Promise . reject ( error ) ; } instance . interceptors . response . use ( success , error ) ; export function initHeaders ( user ) { if ( has ( user , "access_token" ) ) { instance . defaults . headers . accessToken = '' ; } else if ( has ( user , "accessToken" ) ) { instance . defaults . headers . accessToken = '' ; } else { } } export function resetHeaders ( ) { delete instance . defaults . headers . userId ; delete instance . defaults . headers . accessToken ; } export default instance as { request < T = any > ( config ) : Promise < T > ; get < T = any > ( url , config ? ) : Promise < T > ; delete < T = any > ( url , config ? ) : Promise < T > ; head < T = any > ( url , config ? ) : Promise < T > ; post < T = any > ( url , data ? , config ? ) : Promise < T > ; put < T = any > ( url , data ? , config ? ) : Promise < T > ; patch < T = any > ( url , data ? , config ? ) : Promise < T > ; } ;