Sunday 12 November 2017

Loading data into header partial in Express and Pug

Hello guys, so this is the situation:I have a navigation partial in where I want to load menu with items which I want to fetch from database.But I realized that I will have to query database for every route and pass nav points to the navigation partial (res.render("view", {..., ...., navPoints: thingThatCameFromDB})), duplicating that call in every route.How should I handle this? When I think of this problem I come to conclusion that I will have to query DB every time to get those navigation points, but where should I do this call, in every route controller where I need site navigation (because there is admin part of the site where I do not want navigation to appear)?

Submitted November 12, 2017 at 03:57PM by nikola1970

No comments:

Post a Comment