-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #265 from badger-cash/upgrade-navigation
Major Upgrade (react native & bcash)
- Loading branch information
Showing
43 changed files
with
2,684 additions
and
5,946 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// 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 | ||
// } | ||
// } | ||
// } | ||
|
||
const API = `https://index-api.bitcoin.com/api`; | ||
|
||
const priceEndpoint = `${API}/v0/cash/price/`; | ||
|
||
const getPrice = async (currency: string = "usd"): Promise<number> => { | ||
try { | ||
const req = await fetch(`${priceEndpoint}${currency.toLowerCase()}`); | ||
const resp = await req.json(); | ||
return resp.price; | ||
} catch (e) { | ||
console.warn(e); | ||
throw e; | ||
} | ||
}; | ||
|
||
export { priceEndpoint, getPrice }; |
Oops, something went wrong.