File tree Expand file tree Collapse file tree
static/extensions/SammerLOL Expand file tree Collapse file tree Original file line number Diff line number Diff line change 377377 return `${ apiURL } projects/getproject?projectID=${ Cast . toString ( args . id ) } &requestType=thumbnail` ;
378378 }
379379
380+ // TODO: either add parameter to get multiple or have a block to get multiple (either say multiple or 20)
380381 async rnd ( ) {
381382 try {
382383 const response = await fetch ( `${ apiURL } projects/getrandomproject` ) ;
383384 if ( ! response . ok ) throw new Error ( "Failed to fetch random project" ) ;
384385 let data = await response . json ( ) ;
385386
386- return data . id ;
387+ return data [ 0 ] . id ;
387388 } catch {
388389 return "" ;
389390 }
393394 const id = this . generateIdWithArgs ( "latestProject" , { } ) ;
394395 let data = this . getCached ( id ) ;
395396
397+ console . log ( data ) ;
398+
396399 try {
397400 if ( data === null ) {
398401 const response = await fetch ( `${ apiURL } projects/getprojects` ) ;
399402 if ( ! response . ok ) throw new Error ( "Failed to fetch latest project" ) ;
400403 data = await response . json ( ) ;
404+ // Check if there are projects in the array
405+ if ( data && data . length ) data = JSON . stringify ( data [ 0 ] ) ;
406+ else return "{}" ;
401407 }
402-
403- // Check if there are projects in the array
404- if ( data && data . length ) data = JSON . stringify ( data [ 0 ] ) ;
405- else return "{}" ;
406-
408+
407409 this . setCached ( id , data , true ) ;
408410 return data ;
409411 } catch {
You can’t perform that action at this time.
0 commit comments