0
I have my paging method working perfectly with this URL:
http://localhost:3000/menuspage
See the code below;
exports.list_all_dataProviders = async (req, res) => {
const { filter, skip, limit, sort, projection } = aqp(req.query);
Menus
.find(filter)
.skip(skip)
.limit(limit)
.sort(sort)
.select(projection)
.exec(async (err, result) => {
if (err) {
return res.status(500).jsonp({message:"There was an internal error listing all the providers " + err});
}
let count = await Menus.find().count()
res.status(200).jsonp({
limit: limit,
skip: skip,
total: count,
data: result
});
});
};
This is the return in json;
{
"total": 17,
"data": [
{
"_id": "5b6abfb085dc590dc042063d",
"id": "donut",
"name": "Donut",
"description": "Coberto com chantilly",
"price": 2.5,
"restaurantId": "bread-bakery"
},
{
"_id": "5b6abfb085dc590dc042063e",
"id": "bread",
"name": "Pão Artesanal Italiano",
"description": "Pão artesanal com queijos italianos",
"price": 15.9,
"restaurantId": "bread-bakery"
},
>>>> e os restos dos registros.....
]
}
What I need is to modify my method in such a way that I can put my URL like this
And he returns me the first page with 4 record.
I’m having trouble modifying this method because I got it ready, and the lack of experience also contributed.