mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-02 06:16:06 +00:00
af84a589c5
* add redux-promise-middleware to package.json and update package-lock.json * intergrate redux-promise-middleware and simplify rates by replacing saga with promise * fix unrelated breaking test * -improve user messaging when network request fails. \n Clean up rates actions and reducers * Address tslint errors
23 lines
626 B
TypeScript
23 lines
626 B
TypeScript
import { handleJSONResponse } from 'api/utils';
|
|
|
|
export const symbols = ['USD', 'EUR', 'GBP', 'BTC', 'CHF', 'REP'];
|
|
const symbolsURL = symbols.join(',');
|
|
// TODO - internationalize
|
|
const ERROR_MESSAGE = 'Could not fetch rate data.';
|
|
const CCApi = 'https://min-api.cryptocompare.com';
|
|
|
|
const CCRates = CCSymbols => `${CCApi}/data/price?fsym=ETH&tsyms=${CCSymbols}`;
|
|
|
|
export interface CCResponse {
|
|
BTC: number;
|
|
EUR: number;
|
|
GBP: number;
|
|
CHF: number;
|
|
REP: number;
|
|
}
|
|
|
|
export const fetchRates = (): Promise<CCResponse> =>
|
|
fetch(CCRates(symbolsURL)).then(response =>
|
|
handleJSONResponse(response, ERROR_MESSAGE)
|
|
);
|