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