@@ -15,11 +15,17 @@ const config={
15
15
class ManageSurveyService {
16
16
17
17
async getSurveys ( ) {
18
- const response = await axios . get ( MANAGESURVEY_API_BASE_URL + "/surveys" , { headers : config } ) . catch ( function ( e ) {
18
+ const response = await axios . get ( MANAGESURVEY_API_BASE_URL + "/surveys" , { config} ) . catch ( function ( e ) {
19
19
Sentry . captureException ( e ) ;
20
- } ) ;
21
- if ( response . config . headers . accesstoken ) {
22
- renew_accessToken ( response . config . headers . accesstoken ) ;
20
+ } )
21
+ if ( response . headers [ "auth-token" ] ) {
22
+ const auth_token = response . headers [ "auth-token" ] . split ( ';' , 2 ) [ 0 ] . split ( '=' , 2 ) [ 1 ]
23
+ const access_Token = auth_token . split ( ":" , 4 ) [ 1 ]
24
+ const refresh_Token = auth_token . split ( ":" , 4 ) [ 3 ]
25
+ renew_accessToken ( access_Token , refresh_Token ) ;
26
+ }
27
+ if ( response . status === 401 ) {
28
+ initialize ( )
23
29
}
24
30
return response ;
25
31
}
@@ -30,11 +36,17 @@ class ManageSurveyService {
30
36
console . log ( '[updateSurvey] - memberId' , memberId ) ;
31
37
console . log ( '[updateSurvey] - accessToken' , accessToken ) ;
32
38
console . log ( '[updateSurvey] - refreshToken' , refreshToken ) ;
33
- const response = await axios . patch ( `/surveys/${ surveyId } ` , { headers : config } ) . catch ( function ( e ) {
39
+ const response = await axios . patch ( `/surveys/${ surveyId } ` , { config} ) . catch ( function ( e ) {
34
40
Sentry . captureException ( e ) ;
35
- } ) ;
36
- if ( response . config . headers . accesstoken ) {
37
- renew_accessToken ( response . config . headers . accesstoken ) ;
41
+ } )
42
+ if ( response . headers [ "auth-token" ] ) {
43
+ const auth_token = response . headers [ "auth-token" ] . split ( ';' , 2 ) [ 0 ] . split ( '=' , 2 ) [ 1 ]
44
+ const access_Token = auth_token . split ( ":" , 4 ) [ 1 ]
45
+ const refresh_Token = auth_token . split ( ":" , 4 ) [ 3 ]
46
+ renew_accessToken ( access_Token , refresh_Token ) ;
47
+ }
48
+ if ( response . status === 401 ) {
49
+ initialize ( )
38
50
}
39
51
return response ;
40
52
//axios.put(MANAGESURVEY_API_BASE_URL + '/' + surveyId, survey);
@@ -43,9 +55,15 @@ class ManageSurveyService {
43
55
async updateSurvey2 ( surveyId ) {
44
56
const response = await axios . patch ( MANAGESURVEY_API_BASE_URL + "/surveys" + '/' + surveyId , { headers :config } ) . catch ( function ( e ) {
45
57
Sentry . captureException ( e ) ;
46
- } ) ;
47
- if ( response . config . headers . accesstoken ) {
48
- renew_accessToken ( response . config . headers . accesstoken ) ;
58
+ } )
59
+ if ( response . headers [ "auth-token" ] ) {
60
+ const auth_token = response . headers [ "auth-token" ] . split ( ';' , 2 ) [ 0 ] . split ( '=' , 2 ) [ 1 ]
61
+ const access_Token = auth_token . split ( ":" , 4 ) [ 1 ]
62
+ const refresh_Token = auth_token . split ( ":" , 4 ) [ 3 ]
63
+ renew_accessToken ( access_Token , refresh_Token ) ;
64
+ }
65
+ if ( response . status === 401 ) {
66
+ initialize ( )
49
67
}
50
68
return response ;
51
69
}
@@ -54,9 +72,15 @@ class ManageSurveyService {
54
72
console . log ( 'manage survey service - memberId' , memberId ) ;
55
73
const response = await axios . get ( `/surveys/${ memberId } ` , { headers :config } ) . catch ( function ( e ) {
56
74
Sentry . captureException ( e ) ;
57
- } ) ;
58
- if ( response . config . headers . accesstoken ) {
59
- renew_accessToken ( response . config . headers . accesstoken ) ;
75
+ } )
76
+ if ( response . headers [ "auth-token" ] ) {
77
+ const auth_token = response . headers [ "auth-token" ] . split ( ';' , 2 ) [ 0 ] . split ( '=' , 2 ) [ 1 ]
78
+ const access_Token = auth_token . split ( ":" , 4 ) [ 1 ]
79
+ const refresh_Token = auth_token . split ( ":" , 4 ) [ 3 ]
80
+ renew_accessToken ( access_Token , refresh_Token ) ;
81
+ }
82
+ if ( response . status === 401 ) {
83
+ initialize ( )
60
84
}
61
85
return response ;
62
86
// return axios.get(MANAGESURVEY_API_BASE_URL + '/' + memberId);
@@ -65,19 +89,31 @@ class ManageSurveyService {
65
89
async getSurveyByStatus ( status ) {
66
90
const response = await axios . get ( MANAGESURVEY_API_BASE_URL + "/surveys" + '/' + status + '/' + memberId , { headers :config } ) . catch ( function ( e ) {
67
91
Sentry . captureException ( e ) ;
68
- } ) ;
69
- if ( response . config . headers . accesstoken ) {
70
- renew_accessToken ( response . config . headers . accesstoken ) ;
92
+ } )
93
+ if ( response . headers [ "auth-token" ] ) {
94
+ const auth_token = response . headers [ "auth-token" ] . split ( ';' , 2 ) [ 0 ] . split ( '=' , 2 ) [ 1 ]
95
+ const access_Token = auth_token . split ( ":" , 4 ) [ 1 ]
96
+ const refresh_Token = auth_token . split ( ":" , 4 ) [ 3 ]
97
+ renew_accessToken ( access_Token , refresh_Token ) ;
98
+ }
99
+ if ( response . status === 401 ) {
100
+ initialize ( )
71
101
}
72
102
return response
73
103
}
74
104
75
105
async deleteSurvey ( surveyId ) {
76
106
const response = await axios . delete ( `${ MANAGESURVEY_API_BASE_URL } /surveys/${ surveyId } /${ memberId } ` , { headers :config } ) . catch ( function ( e ) {
77
107
Sentry . captureException ( e ) ;
78
- } ) ;
79
- if ( response . config . headers . accesstoken ) {
80
- renew_accessToken ( response . config . headers . accesstoken ) ;
108
+ } )
109
+ if ( response . headers [ "auth-token" ] ) {
110
+ const auth_token = response . headers [ "auth-token" ] . split ( ';' , 2 ) [ 0 ] . split ( '=' , 2 ) [ 1 ]
111
+ const access_Token = auth_token . split ( ":" , 4 ) [ 1 ]
112
+ const refresh_Token = auth_token . split ( ":" , 4 ) [ 3 ]
113
+ renew_accessToken ( access_Token , refresh_Token ) ;
114
+ }
115
+ if ( response . status === 401 ) {
116
+ initialize ( )
81
117
}
82
118
return response ;
83
119
}
0 commit comments