title: How to call external api's data from backend to frontend side?
body: <p>I'm trying to weather Api app using node, express and Axios in backend part without using any framework like Angular or react.</p>
  <p>I have 3 main file for my codes.</p>
  <ol>
  <li>index.html</li>
  <li>customer.js (for front end part)</li>
  <li>server.js (for backend part)</li>
  </ol>
  <p>My backend part like below;</p>
  <pre><code>const express = require('express');
  const app = express();
  const axios = require('axios').default;
  
  API_KEY = &quot;***&quot;;
  const PORT =3000;
  
  // app.use(&quot;/static&quot;, express.static(__dirname + '/customer'));
  
  app.get('/', (req, res) =&gt;{
      axios
        .get(`http://api.openweathermap.org/data/2.5/forecast?q=amsterdam&amp;appid=${API_KEY}`)
        .then(resp =&gt; {
           let weatherDetail = resp.data;
           console.log('a single country details: ', weatherDetail);
           res.send(weatherDetail);
        })
        .catch(err =&gt; console.log(err));
    });
  
  app.listen(PORT, () =&gt; console.log(`My app listening on port ${PORT}! `));
  </code></pre>
  <p>When I write localhost:3000 on browser, I can see the weather api's data. However I want to see html file with functions in customer.js and api's data. Therefore I tried to write <code>res.sendFile((__dirname + '/index.html'));</code>  inside <code>app.get('/', (req, res))</code> function. However, in this situation I can see only html page without getting data from backend.</p>
  <p>How can I call data getting from backend part in frontend part inside customer.js file?</p>
  <p>My codes in customer.js like below (but I'm not sure if I use axios agan inside this file)</p>
  <pre class="lang-js prettyprint-override"><code>const apiCall = cityName =&gt; {
      let apiKey = &quot;***&quot;;
      let apiUrl = `https://api.openweathermap.org/data/2.5/weather?q=${cityName}&amp;appid=${apiKey}&amp;units=metric`
      axios
          .get(apiUrl)
          .then(getWeather)
          .catch(err =&gt; {
              console.log(err);
              err.response.status === 404 ? alert(`The country ${cityName} doesn't exist.`) : alert('Server error! Sorry.');
          });
  };
  apiCall(amsterdam)
  
      function getWeather (response) {
          let city = document.querySelector(&quot;#city&quot;);
          city.innerHTML = response.data.name;
  .
  .
  .
  .
  }
  </code></pre>