Script.js файл location.iataCode не работает

В примере, сделанном с помощью django на странице блога Amadeus, при написании файла script.js, в поле onclick="getLocation(\\\''+location.iataCode+'\\\')"> я получаю ошибку, когда я смотрю на коды в примере, он точно такой же, как и код, можете ли вы помочь с этим? Я оставляю файл script.js ниже

const toLocationData = document.getElementById("toLocationData");
function handleToLocation(){
    let locationE1 = "";
    const toInput = document.getElementById("to").value;
    if(toInput.length >1){
        fetch('/api/v1/flight/select_destination/${toInput}').then((response) => response.json()).then((data) => (toLocationArray = data.data));
        if(toLocationData) {
            toLocationData.style.display = "block";
            toLocationArray.map((location) => {locationE1 += '<div class="card mb-3 mt-3" onclick="getLocation(\\\\'' +location.iataCode+'\\\\')">\\\\<div class="card-header"><b>Name:<b> ' + location.name + '</div>\\\\ <div class="card-body">\\\\ City Name:' + location.address.cityName + "\\\\ <br />\\\\ Country Name:" + location.address.countryName + '\\\\ </div>\\\\ <div class="card-footer">\\\\ <b>SubType:</b>' + location.subType + "\\\\ </div>\\\\ </div>";
        });
        }
    }
    toLocationData.innerHTML = locationE1;
}
function getLocation(regionCode){
    destinationCode = regionCode;
    toLocationData.style.display = "none";
}

Вернуться на верх