Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

98
Vistas
How to use the result of the fetch api in a javascript script with Flask

I have this code in an external Javascript file:

async function sendIso3Info(inCurrency) {
  
  let iso3Info = {
      'text': inCurrency,
  }
  const response = await fetch(`/processIso3Info/${JSON.stringify(iso3Info)}`);
  return await response.text();
}

Here is the part of my template with witch I want use the respond of the 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>

I want replace the 'EUR' and the 'USD' with the result of the fetch. How can I do it?

Patrick

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda