Skip to content

Instantly share code, notes, and snippets.

@fredsced
Created June 10, 2020 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fredsced/87c5cb4f330189c804d71682d8640114 to your computer and use it in GitHub Desktop.
Save fredsced/87c5cb4f330189c804d71682d8640114 to your computer and use it in GitHub Desktop.
_makeConversionAjaxCall(data, successCallback, failureCallback) {
var originCurrency = this.state.originCurrency;
var destCurrency = this.state.destinationCurrency;
var payload = {
originAmount: data.newValue || this.state.originAmount,
destAmount: data.newValue || this.state.destAmount,
originCurrency: originCurrency,
destCurrency: destCurrency,
calcOriginAmount: false
}
// determine whether we need to calc origin or dest amount
if (data.currentlyEditing === 'dest') {
payload.calcOriginAmount = true
}
// ajax call for destination amount
// originCurrency, destCurrency, originAmount
axios.get('/api/conversion', {
params: payload
})
.then((resp) => {
successCallback(resp.data);
})
.catch(failureCallback);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment