title: How to pass open weather API data to React front-end with serverless function and axios
body: <p>I'm currently attempting to call the openweather <code>API</code> in a serverless function, pass the response into a 'return' and then get the response with <code>Axios</code> and set my component state with the response.</p>
  <p>However, every time it calls the <code>JSON</code> isn't being sent in the response. Instead, it's just the URL. The state is then updated to be the URL unsurprisingly.</p>
  <p>When I call the <code>API</code> in <code>Postman</code>, it returns the data. So I don't understand what I'm doing wrong.</p>
  <p>The serverless function is obviously wrong. But what do I need to change about my serverless function to return the data, and not just the <code>URL</code>?</p>
  <p>Here's the function:</p>
  <pre><code>module.exports = (req, res) =&gt; {
  
      const url = `https://api.openweathermap.org/data/2.5/weather?q=London&amp;appid=${process.env.OPEN_WEATHER_API}`;
  
      const weatherResponse = url;
  
      return res.status(200).json(weatherResponse);
    };
  </code></pre>
  <p>And then my Axios call in my component calling the serverless function:</p>
  <pre><code>this.state = {
  
        weather: []
  
      }
  
    axios.get(&quot;/api/getCurrentWeather&quot;)
    .then((response) =&gt; {
      this.setState({
        weather: response.data
      })
      console.log(this.state.weather)
    })
    .catch((error) =&gt; {
      console.log(error)
    })
  }
  </code></pre>
  <p>Any pointers would be appreciated!</p>