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

128
Views
El método GET no funciona en una ruta específica en ExpressJS

Cuando trato de obtener datos usando /:user , la función no se ejecuta dentro de la ruta específica, ¿alguien puede averiguar cuál es el error aquí?

 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

Básicamente, su /catalog y /:user son los mismos debido a la estructura. :user también puede ser un catalog . Por lo tanto, pruebe diferentes enfoques de nomenclatura de las rutas ( /info/:user ).

Gracias.

actualización: Pruebe este.

 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!