Answer the question
In order to leave comments, you need to log in
How to distribute data from the server to pages?
Good time.
Let's say data about registered users comes from the server in this way:
app.get('/users', function (req, res) {
User.find(function(err, users) {
var allUsers = [];
for (var i = users.length - 1; i >= 0; i--) {
var person = {
name: users[i].name,
photoMax: users[i].photoMax,
about: users[i].about,
score: users[i].score,
contacts: users[i].contacts
};
allUsers.push(person);
}
res.render('users', {
page: 'users',
user : req.user,
users: allUsers,
});
});
});
- each anotherUser in users
.row
ul
li тут имя
li тут др.данные юзера
Answer the question
In order to leave comments, you need to log in
You may not know, but it's called "pagination", the first link on google leads to https://github.com/expressjs/express-paginate .
As an everywhere.
When processing the request, take into account the necessary page from the get parameter.
In the selection, set limit and offset
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question