File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -23,18 +23,23 @@ export default class MemosClient {
23
23
24
24
25
25
private async request < T > ( url : string , method : string , payload : any ) : Promise < T > {
26
- const resp : AxiosResponse < MemosAPIResponse < T > > = await axios ( {
27
- method : method ,
28
- url : url ,
29
- data : payload ,
30
- } ) ;
31
- if ( resp . status !== 200 ) {
32
- throw "Connect issue" ;
33
- } else if ( resp . status >= 400 && resp . status < 500 ) {
34
- throw resp . data ?. message || "Error occurred" ;
26
+ try {
27
+ const resp : AxiosResponse < MemosAPIResponse < T > > = await axios ( {
28
+ method : method ,
29
+ url : url ,
30
+ data : payload ,
31
+ } ) ;
32
+ if ( resp . status !== 200 ) {
33
+ throw "Something wrong!" ;
34
+ } else if ( resp . status >= 400 && resp . status < 500 ) {
35
+ throw resp . data ?. message || "Error occurred" ;
36
+ }
37
+ const data = resp . data . data ;
38
+ return data ;
39
+ } catch ( error ) {
40
+ throw "Cannot connect to memos server" ;
35
41
}
36
- const data = resp . data . data ;
37
- return data ;
42
+
38
43
}
39
44
40
45
public async getMemos (
You can’t perform that action at this time.
0 commit comments