pagination for character list
This commit is contained in:
@@ -79,8 +79,17 @@ app.post('/api/character', jsonParser, async (req, res) => {
|
||||
const orderBy = req.body.orderBy
|
||||
const count = req.body.count
|
||||
|
||||
const characterData = await Character.findAll({
|
||||
offset: page * count,
|
||||
limit: count
|
||||
})
|
||||
const pageCount = Math.ceil(await Character.count() / count)
|
||||
|
||||
console.log(characterData)
|
||||
console.log(pageCount)
|
||||
|
||||
res.setHeader('Content-Type', 'application/json')
|
||||
res.send(await Character.findAll({ offset: page * count, limit: count }))
|
||||
res.json({characterData, pageCount})
|
||||
})
|
||||
|
||||
app.get('/api/game/:characterId', async (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user