@@ -9,12 +9,10 @@ import adminforth from './adminforth';
99import sanitizeHtml from 'sanitize-html'
1010import debounce from 'debounce' ;
1111import type { AdminForthResourceColumnInputCommon , Predicate } from '@/types/Common' ;
12- import { useI18n } from 'vue-i18n' ;
1312
1413const LS_LANG_KEY = `afLanguage` ;
1514const MAX_CONSECUTIVE_EMPTY_RESULTS = 2 ;
1615const ITEMS_PER_PAGE_LIMIT = 100 ;
17- const { t } = useI18n ( ) ;
1816
1917export async function callApi ( { path, method, body, headers} : {
2018 path : string , method : 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'
@@ -44,11 +42,11 @@ export async function callApi({path, method, body, headers}: {
4442 // if it is internal error, say to user
4543 if ( e instanceof TypeError && e . message === 'Failed to fetch' ) {
4644 // this is a network error
47- adminforth . alert ( { variant :'danger' , message : t ( 'Network error, please check your Internet connection and try again' ) , } )
45+ adminforth . alert ( { variant :'danger' , message : window . i18n ?. global ?. t ( 'Network error, please check your Internet connection and try again' ) , } )
4846 return null ;
4947 }
5048
51- adminforth . alert ( { variant :'danger' , message : t ( 'Something went wrong, please try again later' ) , } )
49+ adminforth . alert ( { variant :'danger' , message : window . i18n ?. global ?. t ( 'Something went wrong, please try again later' ) , } )
5250 console . error ( `error in callApi ${ path } ` , e ) ;
5351 }
5452}
0 commit comments