title: Node.js catch empty POST request body
body: <p>I am trying to catch a POST request with an empty body before it causes my server to crash. I've seen people using bodyparser but I am using the MVC model and basically I don't have references to app in this .js file. </p>
  
  <pre><code>var resource = req.body;
  if(!resource) return res.status(400).send("Your request is missing details.");
  </code></pre>
  
  <p>I was told to try something like this but it still does not work. When I console.log resource it appears as "{}" even when no body was added in postman, so the null check doesn't work. If anyone has any advice I would appreciate it!</p>