@@ -42,29 +42,31 @@ async function pullData() {
4242 fetchJson ( CEXS_DATA_URL )
4343 . then ( ( data ) => data . cexs ?? [ ] )
4444 . catch ( ( ) => [ ] ) ,
45- fetch ( `${ process . env . TASTY_API_URL } /metrics?startAt=${ startAt } &endAt=${ endAt } &unit=day&type=url` , {
46- headers : {
47- Authorization : `Bearer ${ process . env . TASTY_API_KEY } `
48- }
49- } )
50- . then ( ( res ) => res . json ( ) )
51- . then ( ( res ) => {
52- const tastyMetrics = { }
53- const trendingRoutes = [ ]
54- let i = 0
55- for ( const xy of res ) {
56- if ( i <= 20 ) {
57- trendingRoutes . push ( [ xy . x , xy . y ] )
45+ process . env . TASTY_API_URL
46+ ? fetch ( `${ process . env . TASTY_API_URL } /metrics?startAt=${ startAt } &endAt=${ endAt } &unit=day&type=url` , {
47+ headers : {
48+ Authorization : `Bearer ${ process . env . TASTY_API_KEY } `
5849 }
59- tastyMetrics [ xy . x ] = xy . y
60- i ++
61- }
62- return { tastyMetrics, trendingRoutes }
63- } )
64- . catch ( ( e ) => {
65- console . log ( 'Error fetching tasty metrics' , e )
66- return { tastyMetrics : { } , trendingRoutes : [ ] }
67- } )
50+ } )
51+ . then ( ( res ) => res . json ( ) )
52+ . then ( ( res ) => {
53+ const tastyMetrics = { }
54+ const trendingRoutes = [ ]
55+ let i = 0
56+ for ( const xy of res ) {
57+ if ( i <= 20 ) {
58+ trendingRoutes . push ( [ xy . x , xy . y ] )
59+ }
60+ tastyMetrics [ xy . x ] = xy . y
61+ i ++
62+ }
63+ return { tastyMetrics, trendingRoutes }
64+ } )
65+ . catch ( ( e ) => {
66+ console . log ( 'Error fetching tasty metrics' , e )
67+ return { tastyMetrics : { } , trendingRoutes : [ ] }
68+ } )
69+ : Promise . resolve ( { tastyMetrics : { } , trendingRoutes : [ ] } )
6870 ] )
6971
7072 if ( ! fs . existsSync ( CACHE_DIR ) ) {
0 commit comments