import * as exchangeApi from '../../apis/exchangeApi' import { call, put, takeLatest } from 'redux-saga/effects' import { showToastError } from '../../utils/errorHelper' import { globalActions as actions } from '.' export function* getExchangeRate() { let response = null try { response = yield call(exchangeApi.getExchangeRateBNBToUSD) const { data } = response.data data.priceBNB = data.price_BNB delete data.price_BNB yield put(actions.getExchangeRateSuccess({ exchangeRate: data })) } catch (error) { yield put(actions.getExchangeRateFailed()) showToastError(error) } } export default function* globalSaga() { yield takeLatest(actions.getExchangeRate.type, getExchangeRate) }