title: Checking Status Code in Angular 5
body: <p>I am using .NET Core 2.1 API in my Angular APP</p>
  
  <p>Below is my API</p>
  
  <pre><code>[HttpPost("[action]")]
      public ObjectResult CheckLogIn([FromBody] LogIn model)
      {
          try
          {
              UserInfo user = new UserInfo();
              using (IDbConnection db = new SqlConnection(configuration.GetConnectionString("constr")))
              {
                  user = db.Query&lt;UserInfo&gt;("SP_Loginportal",
                      new
                      {
                          UserId = model.EmployeeCode,
                          Password = util.EncryptMD5(model.Password)
                      }, commandType: CommandType.StoredProcedure).FirstOrDefault();
              }
              if (user != null)
              {
                  return StatusCode(200, user);
              }
              else
              {
                  return StatusCode(401, new ResultSet() { Message = "Invalid Credential or Unauthorized", StatusCode = 401 });
              }
          }
          catch (SqlException sx)
          {
              return StatusCode(503, new ResultSet() { Message = "Service is Currently Unavailable", StatusCode = 503 });
          }
          catch (Exception ex)
          {
              return StatusCode(500, new ResultSet() { Message = ex.Message, StatusCode = 500 });
          }
          finally
          {
          }
          return StatusCode(404, new UserInfo());
      }
  </code></pre>
  
  <p>And in angular</p>
  
  <pre><code>LogIn() {
  const httpOptions = {
    headers: new HttpHeaders({
      'Content-Type': 'application/json'
    })
  };
  var payload = JSON.stringify(this.login);
  var url = this.baseURL + 'api/LogIn/CheckLogIn/';
  this.http.post&lt;UserInfo&gt;(url, payload, httpOptions)
    .subscribe(result =&gt; {
      if (result != null) {
        sessionStorage.setItem("UserID", result.StaffCode);
        sessionStorage.setItem("UserName", result.StaffName);
        sessionStorage.setItem("UserRole", result.StaffRole);
        sessionStorage.setItem("BrancName", result.BranchName);
        sessionStorage.setItem("BranchCode", result.BranchCode);
        this.router.navigate(['/indusindform'])
      }
      else {
        this.ErrorMessage = "Invalid";
      }
    }, error =&gt; console.error(error))
  </code></pre>
  
  <p>}</p>
  
  <p>In http.post call , inside subscribe block I want to check whether API Status Code is 200 or 401 , 503 or 500 , than on basis of that I want to display message which I am returning in ResultSet.</p>
  
  <p>How can I check API status Code before Using its data ?</p>