title: Fetch data from nodejs to a reactjs component
body: <p>I built my react app.
  I have 2 main folders. The first folder contains my react-app and the second contains my nodejs server. In the first file i've created 2 pages and i want to fetch data from nodejs server to one of my page from react app. </p>
  
  <pre><code>//Here is my nodejs file 
  var express = require('express');
  var app = express();
  
  app.post('/', function (req, res) {
    res.send('POST request to the homepage');
  });
  
  app.listen(4000, function () {
    console.log('Example app listening on port 4000!');
  });
  </code></pre>
  
  
  
  <pre><code>//Here is my react page where i want to fetch data from nodejs
  import React, { useState, useEffect } from 'react';
  const Home = () =&gt; {
  
    useEffect(async function () {
        const url = 'http://localhost:4000/';
        const response =  await fetch(url);
        const data = await response.json();
        console.log(data)
      });
  
    return(
      &lt;div&gt;
        &lt;h1&gt;Home Page&lt;/h1&gt;
        &lt;p&gt;{data}&lt;/p&gt;
      &lt;/div&gt;
    )
  }
  
  export default Home;
  </code></pre>
  
  <p>In the future i want to get data also from a nosql database using nodejs, but now I can't pass data from one node js file into reactjs file. How to do this?</p>