Estoy tratando de acceder a la clave total del objeto data.stats de Cryptoranking RapidApi pero arroja este error:
./src/components/Homepage.jsx 17:25
El análisis del módulo falló: Token inesperado (17:25) Es posible que necesite un cargador adecuado para manejar este tipo de archivo. isFetching = _useGetCryptosQuery.isFetching;
var globalStats = datos?.datos?.stats;
if (isFetching) return / # PURE /React.createElement(Loader, { __self: _this,
Intenté todo lo que sabía hasta ahora para resolver esto (desestructuración de objetos, reinstalar reaccionar, actualizar babel), pero nada funciona.
Aquí está el archivo Homepage.jsx:
import React from 'react' import millify from 'millify'; import { Typography, Row, Col, Statistic } from 'antd'; import { Link } from 'react-router-dom'; import { useGetCryptosQuery } from '../services/cryptoApi'; import Loader from './Loader'; const { Title } = Typography; const Homepage = () => { const { data, isFetching } = useGetCryptosQuery(); const globalStats = data?.data?.stats; if(isFetching) return <Loader />; console.log(data); console.log(globalStats); return ( <> <Title level={2} className='heading'>Global Crypto Stats</Title> <Row> <Col span={12}> <Statistic title='Total Cryptocurrencies' value={globalStats.total}/></Col> <Col span={12}> <Statistic title='Total Exchanges' value='4'/></Col> <Col span={12}> <Statistic title='Total Market Cap' value='5'/></Col> <Col span={12}> <Statistic title='Total 24h Volume' value='5'/></Col> <Col span={12}> <Statistic title='Total Markets' value='5'/></Col> </Row> </> ) } export default Homepage;Si consola. log (datos), los datos de la API se registran perfectamente bien. Pero todavía no puedo acceder a data.stats.total .
Imagen de resultado de Console.log
¿Algunas ideas? ¡Gracias!