Email Form App: NodeJs + Express - Cannot GET /

I'm getting this cannot GET error whenever I run my app on a live server with VS Code. My best guess is that it has to do with my routing being incorrect, I'm just not sure what about my routing is wrong. Any sort of help is appreciated <3

The goal is to send a POST request with the user's email inputted into a form element when the app is finished.


const express = require('express');
const request = require('request');
const bodyParser = require('body-parser');
const path = require('path');

const app = express();


app.use(bodyParser.urlencoded({extended: false}));

console.log("The directory is:", (path.join(__dirname, '/site')));

app.use(express.static(path.join(__dirname, '/site')));'/', (req, res) => {

app.listen(5000, console.log('Server started!'))


<form action="/subscribe" method="POST">
  <div class="newsletter-form-grp">
     <i class="far fa-envelope"></i>
    <input name="email" id="email" required pattern="[a-z0-9.%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$" type="email" placeholder="Enter your email...">
  <button id="cta">SUBSCRIBE <i class="fas fa-paper-plane"></i></button>

JS Code inside landing.html

   //form submission
   let cta = document.getElementById('cta');
   let email = document.getElementById('email').value;
   let status = document.getElementById('status');

   cta.addEventListener('click', (event) => {

       if( == null || == "") {
       } else {
              let fetchData = {
                 method: 'POST',
                 body: JSON.stringify({email:, js: true}),
                 headers: {"Content-Type": "application/json"}

              fetch('/subscribe', fetchData)
                 .then(res => {
                   if(res.ok) {
                                // yay
                   } else {

JSON Package

  "name": "Main",
  "version": "1.0.0",
  "description": "",
  "main": "site/js/app.js",
  "dependencies": {
    "body-parser": "^1.19.0",
    "express": "^4.17.1",
    "index": "^0.4.0",
    "request": "^2.88.2"
  "devDependencies": {
    "nodemon": "^2.0.15"
  "scripts": {
    "serve": "node app",
    "dev": "nodemon app"
  "keywords": [],
  "author": "",
  "license": "ISC"

Project Tree:

1 answer

  • answered 2021-11-23 03:03 Old Geezer

    Your landing.html is a static file (in the site folder?), and you also do not have a GET route defined in Express to serve this page. So, in order to access it from your browser, you need to use: http://localhost:5000/landing.html.

    Your form says: <form action='/subscribe' action='POST'>. Therefore, your Express needs this route defined:"/subscribe", (req, res) => {
       res.send("got it!"); 

    BTW, your Html doesn't have an element with id of status. Your subscribe button click event code will hit an error.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum