Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!