File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -97,9 +97,19 @@ async function fetchGamerPowerGiveaways() {
9797 throw new Error ( `Failed to fetch GamerPower data: ${ response . statusText } ` ) ;
9898 }
9999
100- const items = await response . json ( ) ;
101- console . log ( `Fetched ${ items . length } giveaways from GamerPower` ) ;
102- return items ;
100+ const data = await response . json ( ) ;
101+
102+ // Handle "no active giveaways" response: {"status":0,"status_message":"No active giveaways available..."}
103+ if ( ! Array . isArray ( data ) ) {
104+ if ( data . status === 0 && data . status_message ) {
105+ console . log ( `GamerPower: ${ data . status_message } ` ) ;
106+ return [ ] ;
107+ }
108+ throw new Error ( `Unexpected GamerPower response: ${ JSON . stringify ( data ) } ` ) ;
109+ }
110+
111+ console . log ( `Fetched ${ data . length } giveaways from GamerPower` ) ;
112+ return data ;
103113}
104114
105115function filterUnclaimedGiveaways ( giveaways ) {
You can’t perform that action at this time.
0 commit comments