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

138
Views
Cómo asignar el parámetro id del servidor json a un nombre personalizado

Estoy usando el json-server del módulo npm para simular una interfaz REST simple. Como planeo personalizar un poco su funcionalidad, estoy iniciando un servidor express y definiendo el servidor json como un middleware.

El servidor json lee sus objetos de respuesta de un archivo JSON. Me gustaría solicitar un objeto específico de este archivo JSON y, por lo tanto, definir la clave de identificación como mi variable de ruta.

Esto es lo que he probado hasta ahora:

 const jsonServer = require('json-server') const server = jsonServer.create() const router = jsonServer.router('db.json') const middlewares = jsonServer.defaults() server.use(middlewares) server.get('students/:myId', (req, res) => { res.jsonp(req.query) })

Bueno, no funciona. Quiero mapear la variable de ruta :myId myId en :id , ya que el servidor json puede manejar esto más tarde. ¿Hay una manera de lograr esto?

about 4 years ago · Juan Pablo Isaza
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!