title: how to fix GET net::ERR_FAILED
body: <p>i am very very new to backend and express js. I wanted to fetch data from my rest api but it is sending this error net::ERR_FAILED.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//my api
  
  const express = require("express");
  const app = express();
  app.get("/", (req, res)=&gt;{
      res.send("hello world!!!")
  })
  const videos = {
      "source": "....com",
      "url": "...com"
  }
  app.get("/api/home", (req, res)=&gt;{
      res.send(videos)
  })
  app.listen(3500, ()=&gt;console.log("listening at port 3500..."))</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Hey&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;button onclick="init()"&gt;hey&lt;/button&gt;
          
          &lt;script&gt;
              function init(){
                  const url = "http://localhost:3500/api/home"
                  fetch(url).then(res=&gt;res.json()).then(result=&gt;{
                      console.log(result)
                  })
              }
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>I want to console log the data <code>videos</code> from the api when i click the button, but its not working.</p>
  <p>it even says:</p>
  <p>Access to fetch at 'http://localhost:3500/' from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
  index.html:12 GET http://localhost</p>