title: Get data from Node endpoint and pass into React frontend
body: <p>I am accessing a get request from a local node server and am receiving the databack into the React code but I don't know how to then use the received data. Complete beginner with React and Node.</p>
  
  <pre><code>const https = require("https");
  const url =
  "http://localhost:9001/products";
   https.get(url, res =&gt; {
      res.setEncoding("utf8");
      let body = ""
      res.on("data", data =&gt; {
          body += data;
      });
      res.on("end", () =&gt; {
        console.log(
            body
        );
      });
  });
  </code></pre>
  
  <p>The console shows all the data being returned but now I want to use that data, pass it into a cost to be exported using</p>
  
  <pre><code>export default data;
  </code></pre>
  
  <p>whenever I try to alert the body outside of the cont url code, it says undefined. How to I grab the data to export?</p>