@@ -30,39 +30,42 @@ export function jsonResponseWrapper(response: any) {
3030}
3131
3232export function headResponseWrapper ( response : any , headReqType : HeadReqType ) {
33- return new Promise ( ( resolve , reject ) => {
34- let type : string = resType . SUCCESS ;
35- let error : string = '' ;
36- switch ( response . status ) {
37- case 302 :
38- error =
39- headReqType === HeadReqType . EMAIL
40- ? 'Email already registered.'
41- : 'Username already taken.' ;
42- type = resType . ERROR ;
43- break ;
44- case 409 :
45- error =
46- headReqType === HeadReqType . PROFILE
47- ? 'Update not successful. Please try again'
48- : 'Please try again' ;
49- type = resType . ERROR ;
50- break ;
51- case 401 :
52- error =
53- headReqType === HeadReqType . PASSWORD
54- ? 'Incorrect old password.'
55- : 'Please try again with correct password' ;
56- type = resType . ERROR ;
57- break ;
58- case 500 :
59- case 403 :
60- error = headReqType === HeadReqType . OTHERS ? '' : '' ;
61- type = resType . ERROR ;
62- }
63- resolve ( {
64- error,
65- type,
33+ return response . text ( ) . then ( ( data : any ) => {
34+ return new Promise ( ( resolve , reject ) => {
35+ let type : string = resType . SUCCESS ;
36+ let error : string = '' ;
37+ switch ( response . status ) {
38+ case 302 :
39+ error =
40+ headReqType === HeadReqType . EMAIL
41+ ? 'Email already registered.'
42+ : 'Username already taken.' ;
43+ type = resType . ERROR ;
44+ break ;
45+ case 409 :
46+ error =
47+ headReqType === HeadReqType . PROFILE
48+ ? 'Update not successful. Please try again'
49+ : 'Please try again' ;
50+ type = resType . ERROR ;
51+ break ;
52+ case 401 :
53+ error =
54+ headReqType === HeadReqType . PASSWORD
55+ ? 'Incorrect old password.'
56+ : 'Please try again with correct password' ;
57+ type = resType . ERROR ;
58+ break ;
59+ case 500 :
60+ case 403 :
61+ error = headReqType === HeadReqType . OTHERS ? '' : '' ;
62+ type = resType . ERROR ;
63+ }
64+ resolve ( {
65+ error,
66+ type,
67+ body : data ,
68+ } ) ;
6669 } ) ;
6770 } ) ;
6871}
0 commit comments