Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.get("/delete/:id", (req, res) => {
- let postId = parseInt(req.params.id);
- let post = posts.find(post => post.id === postId);
- if (ability.can('delete', post)) {
- posts = posts.filter(cur => cur !== post);
- res.json({ success: true });
- } else {
- res.json({ success: false });
- }
- });
Add Comment
Please, Sign In to add comment