Created
March 23, 2022 08:32
-
-
Save jack-sparroow/cfd45a36ba7258c9ab02c551ff29a58c to your computer and use it in GitHub Desktop.
Pagination API using Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.get('/allpost',JWTAuthenticatToken, async (req, res) => { | |
try{ | |
const post = await Post.find()..skip((page_size * page_number)-page_size)).limit(page_size) | |
res.json(post) | |
}catch(error){ | |
res.json({message:error}) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment