blob: 06d8fceb4b76c97954c9bc76e444281fd9142d5a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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;
};
|