@@ -395,25 +395,34 @@ const ViewMarket = ({ marketData, item, isExpanded, onOpen, onClose }) => {
395
395
) ;
396
396
} ;
397
397
398
- const queryCurrencies = ( { page, size, category } ) => ( ) => {
399
- let extra = '' ;
400
- if ( category !== DEFAULT_CATEGORY ) {
401
- extra = `category=${ category } &` ;
402
- }
398
+ const onError = ( error ) => {
399
+ console . log ( error ) ;
400
+ console . log ( 'local API may not be running' ) ;
401
+ return [ ] ;
402
+ } ;
403
+
404
+ export const queryCurrencies = ( { page, size, category } ) => ( ) => {
405
+ const extra = category !== DEFAULT_CATEGORY ? `category=${ category } &` : '' ;
403
406
404
407
return axios
405
408
. get (
406
- `https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&${ extra } order=market_cap_desc&per_page=${ size } &page=${ page } &sparkline=true&price_change_percentage=1h%2C24h%2C7d%2C14d%2C30d%2C200d%2C1y` ,
409
+ `https://api.react-tables.com/?proxy=${ btoa (
410
+ `https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&${ extra } order=market_cap_desc&per_page=${ size } &page=${ page } &sparkline=true&price_change_percentage=1h%2C24h%2C7d%2C14d%2C30d%2C200d%2C1y` ,
411
+ ) } `,
407
412
)
408
- . then ( ( result ) => result . data ) ;
413
+ . then ( ( result ) => result . data )
414
+ . catch ( onError ) ;
409
415
} ;
410
416
411
- const queryMarkets = ( id ) => ( ) =>
417
+ export const queryMarkets = ( id ) => ( ) =>
412
418
axios
413
419
. get (
414
- `https://api.coingecko.com/api/v3/coins/${ id } /tickers?per_page=5&page=1&include_exchange_logo=true` ,
420
+ `https://api.react-tables.com/?proxy=${ btoa (
421
+ `https://api.coingecko.com/api/v3/coins/${ id } /tickers?per_page=5&page=1&include_exchange_logo=true` ,
422
+ ) } `,
415
423
)
416
- . then ( ( res ) => res . data ) ;
424
+ . then ( ( res ) => res . data )
425
+ . catch ( onError ) ;
417
426
418
427
const Demo = ( ) => {
419
428
// dropdown
@@ -502,9 +511,9 @@ const Demo = () => {
502
511
503
512
React . useEffect ( ( ) => {
504
513
pagination . fns . onSetPage ( DEFAULT_PAGE ) ;
505
- pagination . fns . onSetSize ( 50 ) ; // TODO
514
+ pagination . fns . onSetSize ( 10 ) ; // TODO
506
515
fetchCurrencies (
507
- { page : DEFAULT_PAGE , size : 50 , category : activeCategory } ,
516
+ { page : DEFAULT_PAGE , size : 10 , category : activeCategory } ,
508
517
{ overlayLoading : true } ,
509
518
) ;
510
519
} , [ activeCategory ] ) ;
0 commit comments