SHARE
TWEET

Untitled

a guest May 23rd, 2019 77 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.insert(req.body, (err, response) => {
  6.             if (err) res.status(500).json({ error: { message: err.message }, payload: null });
  7.             else if (response.length) res.status(201).json({ error: 0, payload: { comments: response } });
  8.             else res.location(`${req.originalUrl}`).status(303).json();
  9.         });
  10.     } catch (err) {
  11.         res.status(500).json({ error: { code: '500', message: err.message }, payload: null });
  12.     }
  13. }
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
 
Top