I am trying to add some links to a list of items. The list is made using a for loop.
for(i=0;i<links.length;i++){
<li>
<a href = "<%=links[i].path%>" > ListItem </a>
</li>
}
working fine with some of the links but others are nested links , like /path1/path2
How can I add such links using the for loop?
Edit: Links are from this array
const links = [
{
link: "/product1",
title: "A",
},
{
link: "/product2",
title: "A",
},
{
link: "/product3",
title: "A",
},
];
Paths are defined like this
function router (lists){
Product1Router.get('/',function(req,res){
productdata.find()
.then(function (products) {
res.render('products',{
products,
lists
});
})
})
return products1Router;
}
But the problem is unable to access list item 3, which is prod/path2, while the fr loop only adds /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;
}