JSFiddle - React, Tailwind, and code Playground

JavaScript

angular.module('testApp')
  .factory('AuthService', function ($http) {
    var authService = {};
    authService.login = function (credentials) {
      return $http
        .post('http://localhost/test/login',credentials)
        .success(function (res) {          
          console.log('success');
          return res.id;
        }).error(function(){
          console.log('error');
        });
    };
      return authService;
  });
angular.module('testApp')
  .factory('authInterceptor', function ($rootScope, $q,AuthEvents) {
    return {
      responseError: function (response) {
        $rootScope.$broadcast({
          412: AuthEvents.notAuthenticated,
          403: AuthEvents.notAuthorized,
          417: AuthEvents.sessionTimeout,
          498: AuthEvents.sessionTimeout
        }[response.status], response);
        return $q.reject(response);
      }
    };
  });