angular - Using Service in HttpInterceptor - Angular2 -
i have httpinterceptor starts this:
@injectable() export class interceptedhttp extends http { constructor(backend: connectionbackend, defaultoptions: requestoptions) { super(backend, defaultoptions); } i use service, have created , used in many other components. if add service constructor, it, exception. obivously because constructor cannot differ extended class:
error: supplied parameters not match signature of call target.
is still possible use service in interceptedhttp class?
it no longer recommended extend http. if using angular 4.3+, should implement httpinterceptor
import {injectable} '@angular/core'; import {httpevent, httpinterceptor, httphandler, httprequest} '@angular/common/http'; @injectable() export class noopinterceptor implements httpinterceptor { intercept(req: httprequest<any>, next: httphandler): observable<httpevent<any>> { return next.handle(req); } } https://angular.io/guide/http#intercepting-all-requests-or-responses
Comments
Post a Comment