Tengo este código en un archivo Javascript externo:
async function sendIso3Info(inCurrency) { let iso3Info = { 'text': inCurrency, } const response = await fetch(`/processIso3Info/${JSON.stringify(iso3Info)}`); return await response.text(); }Aquí está la parte de mi plantilla con la que quiero usar la respuesta de Fetch:
<script type="text/javascript"> currencyPair = "Wechselkurs " + "{{ srcCurrencyBlock['text'] }}" + " > " + " {{ destCurrencyBlock['text'] }}" + " " let currencyFrom = "{{ srcCurrencyBlock['text'] }}" let currencyTo = "{{ destCurrencyBlock['text'] }}" // ----------------- Hier wird weitergearbeitet -------------------------------------- sendIso3Info(currencyFrom).then(res => console.log(res)); sendIso3Info(currencyTo).then(res => console.log(res)); // ----------------------------------------------------------------------------------- a = [['Tag-Monat-Jahr', 'Wert'], {% for value in historyCurrencys %} {% if value.From == 'EUR' and value.To == 'USD' %} ['{{ value.day }}-{{ value.month }}-{{ value.year}}', {{ value.close }}], {% endif %} {% endfor %} ] google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(function() { drawChart_1( a, currencyPair ); }); </script>Quiero reemplazar el 'EUR' y el 'USD' con el resultado de la búsqueda. ¿Cómo puedo hacerlo?
Patricio