Could you please assist me in extracting data from a JSON object using JS? Below is the snippet of my code:
const currency_one = currencyOne.value;
const currency_two = currencyTwo.value;
const myHeaders = new Headers();
myHeaders.append('apikey', API_KEY);
const requestOptions = {
method: 'GET',
redirect: 'follow',
headers: myHeaders,
};
fetch(
`https://api.apilayer.com/exchangerates_data/convert?to=${currency_one}&from=${currency_two}&amount=${amountOne.value}`,
requestOptions
)
.then((res) => res.text())
.then((data) => console.log(data))
.catch((err) => console.log('error', err));
};
The output displayed on the console is as follows:
{
"success": true,
"query": {
"from": "AED",
"to": "USD",
"amount": 1
},
"info": {
"timestamp": 1662496624,
"rate": 0.27225
},
"date": "2022-09-06",
"result": 0.27225
}
I specifically require access to the "result" section only.
Your assistance is greatly appreciated!