Tuesday, 4 April 2017

How to give a substringed object to the view? Express.js

Hi i am just starting with programming and i am trying to create a very simple blog with Express.js and Mongoose.Whit this code i am printing 6 articles from my database(simple Article Schema: title,content and user) on the front page of my blog.But how can i not display the whole content but just the start 100 letters from the content.How can i pass it to the view?

index: (req, res) => {
  Articles.find({}).limit(6).populate('author').then(articles => {
      res.render('home/index', { articles: articles})
  })



via petko kostadinov

No comments:

Post a Comment