import {SessionService} from "./login"; import {NotificationService} from "./shared/services/notification.service"; /** @ngInject */ export function noosferoAngularRunBlock( $log: ng.ILogService, Restangular: restangular.IService, SessionService: SessionService, NotificationService: NotificationService ) { Restangular.addFullRequestInterceptor((element: any, operation: string, route: string, url: string, headers: string) => { if (SessionService.currentUser()) { (headers)["Private-Token"] = SessionService.currentUser().private_token; } return { headers: headers }; }); Restangular.setErrorInterceptor((response: restangular.IResponse, deferred: ng.IDeferred) => { // return false to break the promise chain and don't call catch return !NotificationService.httpError(response.status, response.data); }); }