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

173
Views
Acceder a puntos finales anidados dentro de un bucle NodeJS

Estoy tratando de agregar algunos enlaces a una lista de elementos. La lista se hace usando un bucle for.

 for(i=0;i<links.length;i++){ <li> <a href = "<%=links[i].path%>" > ListItem </a> </li> }

funciona bien con algunos de los enlaces, pero otros son enlaces anidados, como /path1/path2

¿Cómo puedo agregar dichos enlaces usando el bucle for?

Editar: los enlaces son de esta matriz

 const links = [ { link: "/product1", title: "A", }, { link: "/product2", title: "A", }, { link: "/product3", title: "A", }, ];

Las rutas se definen así.

 function router (lists){ Product1Router.get('/',function(req,res){ productdata.find() .then(function (products) { res.render('products',{ products, lists }); }) }) return products1Router; }

Pero el problema es que no se puede acceder al elemento 3 de la lista, que es prod/path2, mientras que el ciclo fr solo agrega /path2

 function router (lists){ Product2Router.get('/',function(req,res){ productdata.find() .then(function (products) { res.render('products',{ products, lists }); }) }) Product2Router.get('/path2',function(req,res){ res.render('addNew',{ lists }); }); return products1Router; }
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!