@@ -5,7 +5,7 @@ class BaseApi {
55 constructor ( ) {
66 this . request = superagent ;
77 this . headers = { } ;
8- this . baseUrl = 'http://localhost:3000' ;
8+ this . baseUrl = global . baseUrl ;
99 }
1010
1111 /**
@@ -37,14 +37,16 @@ class BaseApi {
3737 const res = await this . request . get ( this . baseUrl + url )
3838 . send ( body )
3939 . set ( headers )
40- . query ( query ) ;
40+ . query ( query )
41+ . ok ( ( res ) => res . status <= 500 ) ;
4142 this . setAllureAttachment ( res ) ;
4243 return res ;
4344 } else {
4445 const res = await this . request . get ( this . baseUrl + url )
4546 . send ( { } )
4647 . set ( headers )
47- . query ( query ) ;
48+ . query ( query )
49+ . ok ( ( res ) => res . status <= 500 ) ;
4850 this . setAllureAttachment ( res ) ;
4951 return res ;
5052 }
@@ -54,7 +56,8 @@ class BaseApi {
5456 url = url . startsWith ( '/' ) ? url : `/${ url } ` ;
5557 const res = await this . request . post ( this . baseUrl + url )
5658 . send ( body )
57- . set ( headers ) ;
59+ . set ( headers )
60+ . ok ( ( res ) => res . status <= 500 ) ;
5861 this . setAllureAttachment ( res ) ;
5962 return res ;
6063 }
@@ -63,7 +66,8 @@ class BaseApi {
6366 url = url . startsWith ( '/' ) ? url : `/${ url } ` ;
6467 const res = await this . request . put ( this . baseUrl + url )
6568 . send ( body )
66- . set ( headers ) ;
69+ . set ( headers )
70+ . ok ( ( res ) => res . status <= 500 ) ;
6771 this . setAllureAttachment ( res ) ;
6872 return res ;
6973 }
@@ -72,15 +76,17 @@ class BaseApi {
7276 url = url . startsWith ( '/' ) ? url : `/${ url } ` ;
7377 const res = await this . request . patch ( this . baseUrl + url )
7478 . send ( body )
75- . set ( headers ) ;
79+ . set ( headers )
80+ . ok ( ( res ) => res . status <= 500 ) ;
7681 this . setAllureAttachment ( res ) ;
7782 return res ;
7883 }
7984
8085 async delete ( url , headers = { } ) {
8186 url = url . startsWith ( '/' ) ? url : `/${ url } ` ;
8287 const res = await this . request . delete ( this . baseUrl + url )
83- . set ( headers ) ;
88+ . set ( headers )
89+ . ok ( ( res ) => res . status <= 500 ) ;
8490 this . setAllureAttachment ( res ) ;
8591 return res ;
8692 }
0 commit comments