In crypto converter calculator Trying to fetch values of selected user input in options of selection of html of give and get, how to declare in the coingecko API to successfully fetch?
const give_select = document.getElementById('give');
const get_select = document.getElementById('get');
const give_qty_enter = document.getElementById('give_qty');
const get_qty_enter = document.getElementById('get_qty');
const rateE1 = document.getElementById('rate');
const swap = document.getElementById('swap');
//fetch currency rates and update the dom
const calculate = () => {
let give = give_select.value;
let get = get_select.value;
let settings = {
"async": true,
"scrossDomain": true,
"url": "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin%2Cxrp%2Cethereum%2Cbnb&vs_currencies=usd%2Cpkr.aed%2Cngn.sar.kwd",
"method": "GET",
"header": {}
}
$.ajax(settings).done(function (response){
Upon executing this code it's not executing
const rate = response.{give}.{get};
rateE1.innerText = `1 ${give} = ${rate} ${get}`
get_qty_enter.value = (give_qty_enter.value * rate).toFixed(5);
})`
I tried with different API it get worked like this way but how to implement it with coingecko API in above code?
fetch(`https://v6.exchangerate-api.com/v6/9eae******8e14679949/latest/${give}`)
.then((res) => res.json())
.then((data) => {
console.log(data);
const rate = data.conversion_rates[get];
rateE1.innerText = `1 ${give} = ${rate} ${get}`
get_qty_enter.value = (give_qty_enter.value * rate).toFixed(5);
});