Fix bugs
This commit is contained in:
parent
9620c9bb1c
commit
1fa7b44c83
3 changed files with 18 additions and 6 deletions
|
@ -37,11 +37,22 @@ const request = {
|
|||
to_code: 'CHF'
|
||||
};
|
||||
|
||||
client.convert(request, function (err, response) {
|
||||
function _moneyToString (m) {
|
||||
return `${m.amount.decimal}.${m.amount.fractional} ${m.currency_code}`;
|
||||
}
|
||||
|
||||
client.getSupportedCurrencies({}, (err, response) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
console.error(`Error in getSupportedCurrencies: ${err}`);
|
||||
} else {
|
||||
const amount = response.amount;
|
||||
console.log(`OUTPUT: ${amount.decimal}.${amount.fractional}`);
|
||||
console.log(`Currency codes: ${response.currency_codes}`);
|
||||
}
|
||||
});
|
||||
|
||||
client.convert(request, function (err, response) {
|
||||
if (err) {
|
||||
console.error(`Error in convert: ${err}`);
|
||||
} else {
|
||||
console.log(`Convert: ${_moneyToString(request.from)} to ${_moneyToString(response)}`);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue