Dear Sir/Madam,


I have implemented the error interceptor. It works fine.


Now, I have a situation where I call the same node.js service in 2 places 
in my application - while I add a new record and when I upload bulk data.


When I add record, if HTTP error is detected, it should display the 
display. But when I am uploading data, the dialog should not be display. I 
will handle the error separately.

Is it possible?


Regards,

Partha


import { HttpInterceptor, HttpRequest, HttpHandler } from 
'@angular/common/http';
import { Injectable } from '@angular/core';

import { GeneralService } from './general.services';

@Injectable()
export class AuthInterceptor implements HttpInterceptor {
constructor(private generalService: GeneralService) {}

intercept(req: HttpRequest<any>, next: HttpHandler) {
const authToken = this.generalService.getToken();
const authRequest = req.clone({
headers: req.headers.set('Authorisation', 'Bearer ' + authToken)
});
return next.handle(authRequest);
}
}

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to