Skip to content

Instantly share code, notes, and snippets.

@clintonyeb
Created May 17, 2020 19:40
Show Gist options
  • Save clintonyeb/71b85b430d1f7c5075ebb0d30dfb5158 to your computer and use it in GitHub Desktop.
Save clintonyeb/71b85b430d1f7c5075ebb0d30dfb5158 to your computer and use it in GitHub Desktop.
//called from CurrencyCardDisplay component calls GET_CURRENCY_PAIR currencyReducer
export const fetchCurrency = () => dispatch => {
dispatch({type: 'INIT_GET_CURRENCY_NAME_REQUEST'})
fetch('https://restsimulator.coderiq.io/currency_pairs')
.then(function(response) {
return response.json();
})
.then(function(currencyJSON) {
console.log(JSON.stringify(currencyJSON));
dispatch({
type: "GET_CURRENCY_PAIR",
payload: currencyJSON
})
});
}
//called from CurrencyCardDisplay component calls COUNTRY_CHANGE currencyReducer
export const changeCurrency = (countryCode, index) => dispatch => {
dispatch({
type: 'COUNTRY_CHANGE',
code: countryCode,
cardPosition: index
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment