File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,14 +33,24 @@ const vm = new Vue({ // eslint-disable-line no-unused-vars
3333 } )
3434 . catch ( ( error ) => {
3535 this . isLoading = false ;
36- if ( 'detail' in error . response . data ) {
37- this . messages . push ( error . response . data . detail ) ;
38- } else if ( 'text' in error . response . data ) {
39- this . messages = error . response . data . text ;
40- }
36+ this . handleError ( error ) ;
4137 } ) ;
4238 } ,
4339
40+ handleError ( error ) {
41+ const problems = Array . isArray ( error . response . data )
42+ ? error . response . data
43+ : [ error . response . data ] ;
44+
45+ problems . forEach ( ( problem ) => {
46+ if ( 'detail' in problem ) {
47+ this . messages . push ( problem . detail ) ;
48+ } else if ( 'text' in problem ) {
49+ this . messages = problem . text ;
50+ }
51+ } ) ;
52+ } ,
53+
4454 download ( ) {
4555 const headers = { } ;
4656 if ( this . format === 'csv' ) {
@@ -66,11 +76,7 @@ const vm = new Vue({ // eslint-disable-line no-unused-vars
6676 document . body . appendChild ( link ) ;
6777 link . click ( ) ;
6878 } ) . catch ( ( error ) => {
69- if ( 'detail' in error . response . data ) {
70- this . messages . push ( error . response . data . detail ) ;
71- } else if ( 'text' in error . response . data ) {
72- this . messages = error . response . data . text ;
73- }
79+ this . handleError ( error ) ;
7480 } ) ;
7581 } ,
7682 } ,
You can’t perform that action at this time.
0 commit comments