Spaces:
Running
Running
File size: 715 Bytes
f19c267 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import React, {useEffect, useState} from 'react';
import { getSimplePrice } from './services/market';
export default function App() {
const [prices, setPrices] = useState<any>({});
useEffect(() => {
(async () => {
try {
const data = await getSimplePrice(['bitcoin','ethereum']);
setPrices(data);
} catch (e) {
console.error(e);
}
})();
}, []);
return (
<div style={{padding:20}}>
<h1>Ivano Crypto - Web</h1>
<ul>
{Object.keys(prices).map(k => (
<li key={k}>
<strong>{k.toUpperCase()}</strong>: ${prices[k].usd} ({prices[k].usd_24h_change.toFixed(2)}%)
</li>
))}
</ul>
</div>
);
}
|