interceptors TypeError: Cannot read property 'data' of undefined
<p>I am getting <code>TypeError: Cannot read property 'data' of undefined</code> in HTTP interceptor.</p>

<pre><code>//Traceback

angular.js:11706TypeError: Cannot read property 'data' of undefined
    at q (restangular.min.js:6)
    at angular.js:13318
    at n.$eval (angular.js:14570)
    at n.$digest (angular.js:14386)
    at n.$apply (angular.js:14675)
    at l (angular.js:9725)
    at F (angular.js:9915)
    at XMLHttpRequest.C.onload (angular.js:9856)

//interceptors.js

'use strict';

app.factory('HTTP403Interceptor',
    ['$q', '$location',
      function ($q, $location) {
        var deferred = $q.defer();
        return {
          'responseError': function(response) {
            if(response.status === 403) {
              $location.path('/access/login/');
            }
            else return deferred.reject(response);
          }
        }
      }
    ]
  );

//config.router.js

    angular.module('app')
  .run(
    [ '$rootScope', '$state', '$stateParams', '$auth',
      function ($rootScope, $state, $stateParams, $auth) {
        $rootScope.$state = $state;
        $rootScope.$stateParams = $stateParams;
        $rootScope.$on('$stateChangeStart',
          function (event, toState) {
            var loginRequired = false;
            var skipRequired = false;
            // check if this state need login
            if (toState.data &amp;&amp; toState.data.loginRequired) {
              loginRequired = true;
            }
            // if yes and if this user is not logged in, redirect him to login page
            if (loginRequired &amp;&amp; !$auth.isAuthenticated()) {
              event.preventDefault();
              $state.go('access.login');
            }
            // check if this state need skipping
            if (toState.data &amp;&amp; toState.data.skipRequired) {
              skipRequired = true;
            }
            // if yes and if this user is logged in, redirect him to dashboard page
            if (skipRequired &amp;&amp; $auth.isAuthenticated()) {
              event.preventDefault();
              $state.go('app.dashboard');
            }
          }
        );
      }
    ]
  )
  .config(
    [ '$stateProvider', '$urlRouterProvider', 'JQ_CONFIG', '$httpProvider',
      function ($stateProvider, $urlRouterProvider, JQ_CONFIG, $httpProvider) {
        $httpProvider.interceptors.push('HTTP403Interceptor');
        $stateProvider.
        state(
          'access', {
            url: '/access',
            template: '&lt;div ui-view class="fade-in-right-big smooth"&gt;&lt;/div&gt;'
          }
        ).
        state(
          'access.login', {
            url: '/login/',
            templateUrl: '/tpl/auth_tpl/login.html',
            data: {skipRequired: true},
            resolve: {
              deps: ['$ocLazyLoad',
                function( $ocLazyLoad ){
                  return $ocLazyLoad.load( [
                    '/dashboard/js/controllers/auth.Controllers.js'
                  ] );
                }
              ]
            }
          }
        ).state(
          'access.lockme', {
            url: '/lockme/:email/',
            templateUrl: '/tpl/auth_tpl/lockme.html',
            data: {loginRequired: true},
            resolve: {
              deps: ['$ocLazyLoad',
                function( $ocLazyLoad){
                  return $ocLazyLoad.load('toaster').then(
                    function(){
                      return $ocLazyLoad.load('/dashboard/js/controllers/auth.Controllers.js');
                    }
                  );
                }
              ]
            }
          }
        ).state(
          'access.logout', {
            url: '/logout/',
            template: null,
            data: {loginRequired: true},
            controller: 'LogoutController',
            resolve: {
              deps: ['$ocLazyLoad',
                function( $ocLazyLoad){
                  return $ocLazyLoad.load('/dashboard/js/controllers/auth.Controllers.js');
                }
              ]
            }
          }
        ).
        state(
          'access.signup', {
            url: '/signup/',
            templateUrl: '/tpl/auth_tpl/signup.html',
            data: {skipRequired: true},
            resolve: {
              deps: ['$ocLazyLoad',
                function( $ocLazyLoad ){
                  return $ocLazyLoad.load( [
                    '/dashboard/js/controllers/auth.Controllers.js',
                    'ngIntlTelInput'
                  ] );
                }
              ]
            }
          }
        ).
        state(
          'access.verify-email', {
            url: '/verify-email/:school_id/:key/',
            templateUrl: '/tpl/auth_tpl/verifyEmail.html',
            data: {skipRequired: true},
            resolve:{
              deps: ['$ocLazyLoad',
                function ($ocLazyLoad) {
                  return $ocLazyLoad.load([
                      '/dashboard/js/controllers/auth.Controllers.js',
                      '/dashboard/js/controllers/utils.js',
                    ]
                  );
                }
              ]
            }
          }
        ).
        state(
          'access.reset-password', {
            url: '/reset/password/',
            templateUrl: '/tpl/auth_tpl/resetPassword.html',
            data: {skipRequired: true},
            resolve:{
              deps:['$ocLazyLoad',
                function ($ocLazyLoad) {
                  return $ocLazyLoad.load([
                      '/dashboard/js/controllers/auth.Controllers.js'
                    ]
                  );
                }
              ]
            }
          }
        ).
        state(
          'access.reset-password-confirm', {
            url: '/reset/password/confirm/:uid/:token/',
            templateUrl: '/tpl/auth_tpl/resetPasswordConfirm.html',
            data: {skipRequired: true},
            resolve:{
              deps:['$ocLazyLoad',
                function ($ocLazyLoad) {
                  return $ocLazyLoad.load([
                      '/dashboard/js/controllers/auth.Controllers.js'
                    ]
                  );
                }
              ]
            }
          }
        ).
        state(
          'app', {
            abstract: true,
            url: '/app',
            templateUrl: '/tpl/app.html',
            data: {loginRequired: true},
            resolve:{
              deps: ['$ocLazyLoad',
                function ($ocLazyLoad) {
                  return $ocLazyLoad.load([
                    '/dashboard/js/controllers/header.Controller.js'
                  ]);
                }
              ]
            }
          }
        ).
        state(
          'app.dashboard', {
            url: '/dashboard/',
            templateUrl: '/tpl/dashboard.html',
            resolve: {
              deps: ['$ocLazyLoad',
                function( $ocLazyLoad ){
                  return $ocLazyLoad.load([
                    '/dashboard/js/app/todo/todo.js',
                    JQ_CONFIG.moment,
                    '/dashboard/js/controllers/dashboard.Controllers.js',
                    '/dashboard/js/controllers/auth.Controllers.js'
                  ]);
                }
              ]
            }
          }
        )
        $urlRouterProvider.otherwise('/access/login/');
      }
    ]
  );

R {}
__proto__
:
Object
loginRequired
:
true
__proto__
:
Object
__defineGetter__
:
__defineGetter__()
__defineSetter__
:
__defineSetter__()
__lookupGetter__
:
__lookupGetter__()
__lookupSetter__
:
__lookupSetter__()
constructor
:
Object()
hasOwnProperty
:
hasOwnProperty()
isPrototypeOf
:
isPrototypeOf()
propertyIsEnumerable
:
propertyIsEnumerable()
toLocaleString
:
toLocaleString()
toString
:
toString()
valueOf
:
valueOf()
get __proto__
:
__proto__()
set __proto__
:
__proto__()
</code></pre>