I've just started to learn react, and I'm very new to it. Right now I was trying to call some data from free currency conversion API. When I'm calling the api, it returns something like this:
{
"AUD_NZD": 1.089788
}
or
{
"USD_AUD": 1.404502
}
As you can see, the very top level of the returned data is changing as I enter different money type. And here is my code to fetch the data:
const API_INFO = primary + '_' + secondary;
const API_CALL = await fetch(`https://free.currencyconverterapi.com/api/v6/convert?q=${API_INFO}&compact=ultra`);
const API_DATA = await API_CALL.json();
const result = API_DATA.API_INFO;
But the const result is actually returning undefined, as API.DATA.API_INFO does not exist in the returned data.
Is there a way to use dynamic values of API_INFO to actually fetch the conversion rate only?
Cheers.