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

137
Views
GET method not working on specific route in ExpressJS

When I try to get data using /:user the function is not running inside the specific routing, can anyone figure me out what is the mistake here?

const express = require("express");
const app = express();
const mongoose = require("mongoose");
const {accountSC,catalogSC} = require("./schema");

let dburl = **database url**
app.use(express.json());
mongoose.connect(dburl);

app.get("/catalog", async (req, res) => {
  //some func inside it
});

app.get("/:catalog/:id", async (req, res) => {
    //some func inside it
});

app.get("/:user", async (req, res) => {
    //some func inside it
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Basically your /catalog and /:user are the same because of the structure. :user value can be catalog also. So, try out different naming approaches of the routes (/info/:user).

Thank you.

update: Try out this one.

app.get("/catalog", async (req, res) => {
  //some func inside it
});

app.get("/catalog/:catalog/:id", async (req, res) => {
    //some func inside it
});

app.get("/info/:user", async (req, res) => {
    //some func inside it
});
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!