Guest User

Untitled

a guest
Jan 18th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. app.get("/delete/:id", (req, res) => {
  2. let postId = parseInt(req.params.id);
  3. let post = posts.find(post => post.id === postId);
  4. if (ability.can('delete', post)) {
  5. posts = posts.filter(cur => cur !== post);
  6. res.json({ success: true });
  7. } else {
  8. res.json({ success: false });
  9. }
  10. });
Add Comment
Please, Sign In to add comment