title: Handling server side errors in javascript fetch
body: <p>I'm making a script which has server side validation.  When validation fails I have the script throw an exception server side.  I want to access the message in the exception when the response reaches the client side, but I'm having trouble with that.  If I console.log the <code>data</code> I can see the exception, but I want to access it in the <code>catch</code> so I can push the error message to an HTML element on the page.</p>
  <pre><code>    fetch(/* Posting to some PHP script */).then(function(data) {
          
          // Logic here when success  
          console.log(data) // Shows error msg when there is an error 
  
          
      }).catch(function() {
          // Error Handling, I want to push the error msg to HTML element here             
      });
  </code></pre>
  <p>What am I doing wrong here?
  Thanks</p>