File tree Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Expand file tree Collapse file tree 3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 1
1
# midjourney-fetch
2
2
[ ![ npm version] ( https://img.shields.io/npm/v/midjourney-fetch.svg )] ( https://www.npmjs.com/package/midjourney-fetch ) ![ GitHub Workflow Status] ( https://img.shields.io/github/actions/workflow/status/GPTGenius/midjourney-fetch/ci.yml?branch=main ) ![ node-current (scoped)] ( https://img.shields.io/node/v/midjourney-fetch ) ![ GitHub] ( https://img.shields.io/github/license/GPTGenius/midjourney-fetch )
3
3
4
- Fetch api for midjournery on discord
4
+ Fetch api for midjourney on discord
5
5
6
6
## Usage
7
7
``` typescript
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " midjourney-fetch" ,
3
- "version" : " 0.1.1 " ,
3
+ "version" : " 0.1.2 " ,
4
4
"description" : " " ,
5
5
"type" : " module" ,
6
6
"main" : " ./dist/index.js" ,
Original file line number Diff line number Diff line change @@ -90,7 +90,21 @@ export class Midjourney {
90
90
} ,
91
91
} ) ;
92
92
if ( res . status >= 400 ) {
93
- throw new Error ( `[${ res . status } ]Interactions failed` ) ;
93
+ let msg = '' ;
94
+ try {
95
+ const data = await res . json ( ) ;
96
+ if ( this . debugger ) {
97
+ this . log ( 'Request failed' , JSON . stringify ( data ) ) ;
98
+ }
99
+ msg = data ?. message ;
100
+ } catch ( e ) {
101
+ // catch JSON error
102
+ }
103
+ if ( msg ) {
104
+ throw new Error ( msg ) ;
105
+ } else {
106
+ throw new Error ( `Interactions failed with ${ res . status } ` ) ;
107
+ }
94
108
}
95
109
}
96
110
You can’t perform that action at this time.
0 commit comments