File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ const handle = async (ctx: PicGo): Promise<PicGo> => {
46
46
const options = postOptions ( qiniuOptions , img . fileName , getToken ( qiniuOptions ) , base64Image )
47
47
const res = await ctx . Request . request ( options )
48
48
const body = JSON . parse ( res )
49
- if ( body . key ) {
49
+ if ( body ? .key ) {
50
50
delete img . base64Image
51
51
delete img . buffer
52
52
const baseUrl = qiniuOptions . url
@@ -64,11 +64,14 @@ const handle = async (ctx: PicGo): Promise<PicGo> => {
64
64
return ctx
65
65
} catch ( err ) {
66
66
if ( err . message !== 'Upload failed' ) {
67
- const error = JSON . parse ( err . response . body )
68
- ctx . emit ( 'notification' , {
69
- title : '上传失败' ,
70
- body : error . error
71
- } )
67
+ // err.response maybe undefined
68
+ if ( err . response ) {
69
+ const error = JSON . parse ( err . response . body || '{}' )
70
+ ctx . emit ( 'notification' , {
71
+ title : '上传失败' ,
72
+ body : error . error
73
+ } )
74
+ }
72
75
}
73
76
throw err
74
77
}
You can’t perform that action at this time.
0 commit comments