File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,41 @@ util.ajax.interceptors.request.use(function (config) {
29
29
config . headers . common [ "Abp.TenantId" ] = abp . multiTenancy . getTenantIdCookie ( ) ;
30
30
return config ;
31
31
} , function ( error ) {
32
-
32
+
33
33
return Promise . reject ( error ) ;
34
34
} ) ;
35
+ util . ajax . interceptors . response . use ( function ( response ) {
36
+ // Do something with response data
37
+ return response ;
38
+ } , function ( error ) {
39
+ // Do something with response error
40
+ if ( ! ! error . response && ! ! error . response . data && ! ! error . response . data . __abp ) {
41
+ abp . ajax . showError ( error . response . data . error ) ;
42
+ } else {
43
+ if ( ! error . response ) {
44
+ abp . ajax . showError ( abp . ajax . defaultError ) ;
45
+ return
46
+ }
47
+ switch ( error . response . status ) {
48
+ case 401 :
49
+ abp . ajax . handleUnAuthorizedRequest (
50
+ abp . ajax . showError ( abp . ajax . defaultError401 ) ,
51
+ abp . appPath
52
+ ) ;
53
+ break ;
54
+ case 403 :
55
+ abp . ajax . showError ( abp . ajax . defaultError403 ) ;
56
+ break ;
57
+ case 404 :
58
+ abp . ajax . showError ( abp . ajax . defaultError404 ) ;
59
+ break ;
60
+ default :
61
+ abp . ajax . showError ( abp . ajax . defaultError ) ;
62
+ break ;
63
+ }
64
+ }
65
+ return Promise . reject ( error ) ;
66
+ } )
35
67
util . inOf = function ( arr , targetArr ) {
36
68
let res = true ;
37
69
arr . forEach ( item => {
Original file line number Diff line number Diff line change @@ -14,6 +14,14 @@ util.ajax.get('/AbpUserConfiguration/GetAll').then(result=>{
14
14
Vue . use ( VueI18n ) ;
15
15
Vue . use ( iView ) ;
16
16
window . abp = $ . extend ( true , abp , result . data . result ) ;
17
+ abp . ajax . defaultError . message = abp . localization . abpWeb ( 'DefaultError' ) ;
18
+ abp . ajax . defaultError . details = abp . localization . abpWeb ( 'DefaultErrorDetail' ) ;
19
+ abp . ajax . defaultError401 . message = abp . localization . abpWeb ( 'DefaultError401' ) ;
20
+ abp . ajax . defaultError401 . details = abp . localization . abpWeb ( 'DefaultErrorDetail401' ) ;
21
+ abp . ajax . defaultError403 . message = abp . localization . abpWeb ( 'DefaultError403' ) ;
22
+ abp . ajax . defaultError403 . details = abp . localization . abpWeb ( 'DefaultErrorDetail403' ) ;
23
+ abp . ajax . defaultError404 . message = abp . localization . abpWeb ( 'DefaultError404' ) ;
24
+ abp . ajax . defaultError404 . details = abp . localization . abpWeb ( 'DefaultErrorDetail404' ) ;
17
25
Vue . prototype . L = function ( text , ...args ) {
18
26
let localizedText = window . abp . localization . localize ( text , AppConsts . localization . defaultLocalizationSourceName ) ;
19
27
if ( ! localizedText ) {
You can’t perform that action at this time.
0 commit comments