(Regarding a currency conversion tool)
In order to accurately convert currencies, I am looking to access an object structured like this:
rates:
AUD: 1.708562
SGD: 1.546211
When retrieving these rates from an API, they are not always in the desired order. For example, if I request the conversion from USD to GBP, GBP may appear before USD. Therefore, I need a method to retrieve the values based on the requested symbols.
I attempted the following approaches:
const from = res.rates.this.convertFrom.symbol;
// -----AND-----
const fromSymbol = this.convertFrom.symbol;
const from = res.rates.fromSymbol.toString();
Unfortunately, none of these methods yielded the desired results.
For more information, you can visit the codesandbox
Note: The value of this.convertFrom.symbol
corresponds to the user input, which in this case is symbol: 'SGD'