Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
implement rest html frontend PATCH

I'm new to this. To practice, I am currently creating a REST API with nodejs and express, with the following endpoints:

  • GET site.tld/project/21 -> Show Project 21
  • POST site.tld/project/33 -> Create Project 33
  • PATCH site.tld/project/44 -> Change project 44
  • DELETE site.tld/project/55 -> Delete project 55

etc

I want have a Website, to Show, Create, Patch and Delete Projects. So I implement the REST Client in the browser via javascript. I have built a nice frontend with Bootstrap. To send the PATCH requests from the frontend to the backend I use a script with fetch(),

Now my question:

If I want to make an HTTP PATCH or DELETE request to the API, I need the ID of the project. How do I get the ID of the project in the frontend?

I found the following possibilities:

  • Get and Extract the URL with window.location.href in the frontend, since the URL of the Webpage to edit the Project contains the ID, e.g: url is "site.tld/project/33" so the ID are "33".

  • I use ejs templates, I can send the ID from the backend to the frontend, and bind the data to an html data-* Tag and extract this via javascript.

None of this doesn't feel right. Can someone please explain to me what the correct way is?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda