diff options
Diffstat (limited to 'app/utils')
| -rw-r--r-- | app/utils/bitcoin-price.tsx | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/utils/bitcoin-price.tsx b/app/utils/bitcoin-price.tsx new file mode 100644 index 0000000..06d8fce --- /dev/null +++ b/app/utils/bitcoin-price.tsx | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | import { useEffect, useState } from "react"; | ||
| 2 | |||
| 3 | export const BitcoinPrice = () => { | ||
| 4 | const [bitcoinPrice, setBitcoinPrice] = useState(""); | ||
| 5 | |||
| 6 | useEffect(() => { | ||
| 7 | fetch("https://api.kraken.com/0/public/Ticker?pair=xbtusd") | ||
| 8 | .then((res) => res.json()) | ||
| 9 | .then((data) => { | ||
| 10 | const rawPrice = data.result.XXBTZUSD.c[0]; | ||
| 11 | setBitcoinPrice(rawPrice); | ||
| 12 | }); | ||
| 13 | }, []); | ||
| 14 | |||
| 15 | return bitcoinPrice; | ||
| 16 | }; | ||
