Fiber: how Can Full pagination Result

Created on 4 Aug 2020  路  2Comments  路  Source: gofiber/fiber

Create Pagination

how can create pagination for JSON response in controller return like:

perPage
current page
nextPage
total page
and others...

something like Laravel (php) pagination or Rails or other frameworks

馃 Question

All 2 comments

Thanks for opening your first issue here! 馃帀 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

you can create a middleware to treat it or a method too
e.g

func Pagination(data interface{}, pageActual, limitItems int) (result []interface{}, err error) {
    // your logic
}
app.Get("/", func(c *fiber.Ctx) {
    result := Pagination(...)
    c.JSON(fiber.Map{
        "data": result,
        "nextPage: ...
        ....
    })
}

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ahan picture ahan  路  3Comments

petersephrin picture petersephrin  路  4Comments

MohamedGouaouri picture MohamedGouaouri  路  3Comments

peterbourgon picture peterbourgon  路  4Comments

jeyraj picture jeyraj  路  4Comments