bitbox-sdk
Version:
BITBOX SDK for Bitcoin Cash
16 lines (14 loc) • 457 B
text/typescript
import axios, { AxiosResponse } from "axios"
export class Price {
public async current(currency: string = "usd"): Promise<number> {
try {
const response: AxiosResponse = await axios.get(
`https://index-api.bitcoin.com/api/v0/cash/price/${currency.toLowerCase()}`
)
return response.data.price
} catch (error) {
if (error.response && error.response.data) throw error.response.data
else throw error
}
}
}