import axios from "axios" ; import { UserStore } from '../stores' ; import Config from '../config' ; import { configure } from "axios-hooks" ; const initAxios = ( ) => { axios . defaults . baseURL = Config . serverURL || '' ; axios . defaults . headers . common [ 'Authorization' ] = `Bearer ${ UserStore . me ?. access_token || '' }` ; axios . interceptors . response . use ( ( data ) => { if ( data ?. data ?. code === 401 ) { UserStore . loginOut ( ) ; } return data ; } ) ; configure ( { axios } ) ; } ; export default { } ; export { initAxios } ;