Skip to content

Commit

Permalink
Fix pagination issue on endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcrammer committed May 1, 2024
1 parent 5ac8d5b commit 4b76fec
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/routes/payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ router.get("/:user_id", authMiddleware("payments_read"), async (req, res) => {

if (all && userCan(req, "payments_read_all")) delete where.user_id

const payments = await Transaction.findAll({ where, order, limit, offset: page * limit })
const payments = await Transaction.findAll({ where, order, limit, offset: (page - 1) * limit })
const total = await Transaction.count({ where })
res.json({ success: "success", data: payments, page: Number(page), limit: Number(limit), total })
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ router.get("/", authMiddleware("payments_read_all", { allowSelf: true }), async
const subscriptions = await Subscription.findAll({
order: [["createdAt", "DESC"]],
limit,
offset: page * limit,
offset: (page - 1) * limit,
})
const total = await Subscription.count()
res.json({ success: "success", data: subscriptions, page, limit, total })
Expand Down

0 comments on commit 4b76fec

Please sign in to comment.