Hi, I am building simple node js app where i have a profile route which retrives some data from the db and then renders it in an ejs file. Everything worked perfectly until I linked to an external style sheet in that ejs file. Whenever I try accesing the profile route i get the following error:CastError: Cast to ObjectId failed for value "profile-style.css" at path "_id" for model "user"This is my code for the route:router.get('/', authCheck, function(req, res){ Quote.find({userId: req.user.id}).then(function(quotes){ res.render('profile.ejs', {user: req.user, quote: quotes}); }) }); This is my ejs file: <% include partials/log-header %>
You posted the following quotes:
<% for(var i = 0; i < quote.length; i++){ %>
- <%= quote[i].quote %>
<% } %>
I realized that when I link to the external style sheet the href gets assigned to req.user.id instead of the id of the logged in user (I use passport).Could someone explain to me what is happening and how to overcome this problem?Thanks in advance ;)
Submitted July 03, 2018 at 03:04PM by everek123
No comments:
Post a Comment