{"size": 1120, "ext": "js", "max_stars_repo_path": "src/app/components/services/HttpRequestInterceptor.js", "max_stars_repo_name": "tupm58/oexam-huhu", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/app/components/services/HttpRequestInterceptor.js", "max_issues_repo_name": "tupm58/oexam-huhu", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/app/components/services/HttpRequestInterceptor.js", "max_forks_repo_name": "tupm58/oexam-huhu", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 33.9393939394, "max_line_length": 133, "alphanum_fraction": 0.5205357143}
/**
 * Created by MinhTu on 4/7/2017.
 */
(function(){
    angular.module('app')
        .factory('httpRequestInterceptor', [
            '$q','$rootScope',
            httpRequestInterceptor
        ]);

    function httpRequestInterceptor($q,$rootScope){
        return {
            request: function (requestConfig) {
                //default show toaster for all xhr, if some error doesn't need to show then set this var to false when handle failure
                $rootScope.showToaster = true;
                if (localStorage['auth-token']) {
                    requestConfig.headers['Authorization'] = 'JWT ' + localStorage['auth-token'];
                }
                requestConfig.headers['Content-Type'] = 'application/json';
                //$rootScope.isShowOverlay = true;
                return requestConfig;
            },
            response: function (response) {
                // Do nothing on success response
                return response;
            },
            responseError: function (response) {
                return $q.reject(response);
            }
        }
    }
})();
