File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -4,15 +4,17 @@ import { deepMerge } from '../../utils'
4
4
export const AxiosHttpDriverDefaultOptions = {
5
5
tokenType : 'Bearer' ,
6
6
apiBaseURL : '/' ,
7
- authorizationHeader : 'Authorization'
7
+ authorizationHeader : 'Authorization' ,
8
+ responseChecker ( response ) {
9
+ return true
10
+ }
8
11
}
9
12
10
13
export class AxiosHttpDriver {
11
14
constructor ( options ) {
12
15
this . options = deepMerge ( AxiosHttpDriverDefaultOptions , options )
13
16
}
14
17
15
- // Send request helpers
16
18
async sendRequest ( method , url , data = { } , config = { } ) {
17
19
return axios . request ( {
18
20
method,
@@ -22,7 +24,7 @@ export class AxiosHttpDriver {
22
24
...config
23
25
} )
24
26
. then ( response => {
25
- if ( ! response || ! response . data || ! response . data . status || response . data . status !== 'success' ) {
27
+ if ( this . options . responseChecker && ! this . options . responseChecker ( response ) ) {
26
28
throw new Error ( 'API request failed' )
27
29
}
28
30
You can’t perform that action at this time.
0 commit comments