Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

100
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda