title: How to find out if controller should return JSON using wantsJSON
body: <p>I saw that in sails there is a variable in the request object called <code>wantsJSON</code> and in the error pages that gets generated when creating a new project, it shows </p>
  
  <pre><code>if (req.wantsJSON) {
      //Do Something
  } 
  </code></pre>
  
  <p>How does sails decide whether a user wants JSON or not?</p>