Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

224
Views
Having issues with app.post, results in Cannot Get /

I'm trying to create a sign-up page where users can enter information, however, I'm having issues with "app.post" properly working. This is what I have so far:

const express = require("express");

const db = require("./dbConnectExec.js")

const app = express();
app.use(express.json());

app.listen(5000, () => {
    console.log('App is running on port 5000');
});

app.get("/hi", (req,res) => {
    res.send("Hello world.");
});

app.get("/", (req,res) => {
    res.send("API is running.");
});

// app.post();
// app.put();

app.post("/customers", async(req, res) => {
    // res.send("/contacts called");
    // console.log("request body", req.body)

    let nameFirst = req.body.nameFirst;
    let nameLast = req.body.nameLast;
    let email = req.body.email;
    let password = req.body.password;

    let emailCheckQuery = `
    SELECT customer_email
    FROM Customer
    WHERE customer_email = '${email}'`;

    let existingUser = await db.executeQuery(emailCheckQuery);

    console.log("existing user", existingUser);

    if(existingUser[0]){return res.status(409).send("duplicate email")};

})

When I attempt to add a user through Postman, for example:

{"nameFirst": "Robert",
 "nameLast": "Redford",
 "email": "rob@mail.com",
 "password": "asdfasdf"}

I end up with "Cannot GET /customers"

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You have no GET handler for /customers only a POST handler

about 4 years ago · Juan Pablo Isaza Report

0

In postman you can change your request from a GET to a POST request. Once you do it should hit this route endpoint.

note: "GET is used for viewing something, without changing it, while POST is used for changing something. For example, a search page should use GET to get data while a form that changes your password should use POST . Essentially GET is used to retrieve remote data, and POST is used to insert/update remote data."

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!