SHARE
TWEET

Untitled

a guest May 23rd, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const db = require('../../config/database');
  2.  
  3. module.exports = async (req, res) => {
  4.     try {
  5.         db.remove({_id: req.params.id}, {}, (err, response) => {
  6.             if (err)
  7.                 res.status(500).json({ error: { code: '500', message: err.message }, payload: null });
  8.             else if (!response)
  9.                 res.status(404).json({ error: 0, payload: { id: req.params.id } });
  10.             else
  11.                 res.status(200).json({ error: 0, payload: { id: req.params.id, removed: response } });
  12.         });
  13.     } catch (err) {
  14.         res.status(500).json({ error: { code: '500', message: err.message }, payload: null });
  15.     }
  16. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top