How to make a working POST request in node.js bettween server and client. Express

MY CODE

To run:

  1. Open CMD on your laptop.
  2. (Assuming you have everything installed) Navigate to the project folder in CMD using cd.
  3. Type: node index.ts
  4. Go to a browser of your choice.
  5. Click on the address bar.
  6. Type localhost:3000
  7. Your good to go!

What i’m using:

  • Node.js
  • Express
  • Html
  • Typescript
  • Javascript
  • Fetch Api
  • (and if it helps) VS Code

What i’m trying to do:

  • I’m trying to make a POST request from public/index.html to index.ts using fetch.

The problem:

I get this as an output:

{I got a request!!}
{}

The empty {} should house a latitude & longitude as well as a status.


What I have tried:

  • I have tried changing the data that I am fetching (in index.html).
  • I have tried hard coding some values/strings in the fetched variables.
  • I have tried rearranging the code.

NOTHING WORKS!!!