title: Angular + Nodejs API - Best practice to handle request response
body: <p>I'm writing my first API in node.js and front end in Angular.</p>
  
  <p>Wanted to ask what is the best practice for handling responses. So by this i mean should my API always return codes e.g. <code>403</code> or is a <code>success</code> = <code>true</code>/<code>false</code> fine? </p>
  
  <p>Is there any security consideration between the two, i.e. is one more secure?</p>
  
  <p>So in essence which of the 2 below should i use?</p>
  
  <pre><code>if (res.data.success){
     //to do something
  } 
  </code></pre>
  
  <p>vs </p>
  
  <pre><code>if (res.status == 403) {
     //to do something
  }
  </code></pre>
  
  <p>Or am i worrying about nothing?</p>
  
  <p>Thanks.</p>