From 8686078ae801fdc15df5a40ee158a43373d37c1c Mon Sep 17 00:00:00 2001 From: bndw Date: Wed, 26 Apr 2023 17:49:25 -0700 Subject: Initial commit --- app/utils/bitcoin-price.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 app/utils/bitcoin-price.tsx (limited to 'app/utils/bitcoin-price.tsx') 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 @@ +import { useEffect, useState } from "react"; + +export const BitcoinPrice = () => { + const [bitcoinPrice, setBitcoinPrice] = useState(""); + + useEffect(() => { + fetch("https://api.kraken.com/0/public/Ticker?pair=xbtusd") + .then((res) => res.json()) + .then((data) => { + const rawPrice = data.result.XXBTZUSD.c[0]; + setBitcoinPrice(rawPrice); + }); + }, []); + + return bitcoinPrice; +}; -- cgit v1.2.3