diff options
| author | bndw <ben@bdw.to> | 2023-04-26 17:49:25 -0700 |
|---|---|---|
| committer | bndw <ben@bdw.to> | 2023-04-26 17:49:25 -0700 |
| commit | 8686078ae801fdc15df5a40ee158a43373d37c1c (patch) | |
| tree | f8807fa764e917c6c4cdd30dcff31aa4bb060da8 /app/utils | |
Initial commit
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 | }; | ||
