HandlerError JWT TOKEN


#1

hI,

I’m doing my handlerError to control the errors I get when authenticating with jwt, but it sends me this error:

“originalStack”: "Error: Uncaught (in promise): [object Object]\n at new ZoneAwareError (file:///data/data/com.asianmarket.user/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:994:33)\n at resolvePromise (file:///data/data/com.asianmarket.user/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:713:31)\n at resolvePromise (file:///data/data/com.asianmarket.user/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:684:17)\n at file:///data/data/com.asianmarket.user/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:761:17\n at ZoneDelegate.invokeTask (file:///data/data/com.asianmarket.user/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:398:31)\n at Object.onInvokeTask (file:///data/data/com.asianmarket.user/files/app/tns_modules/@angular/core/bundles/core.umd.js:4778:33)\n at ZoneDelegate.invokeTask (file:///data/data/com.asianmarket.user…

intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>{

        const token = Config.token;
        const requestUrl:Array<any> = request.url.split('/');
        const apiUrl: Array<any> = Config.baseUrl.split('/');

        if(token && requestUrl[2] === apiUrl[2]){
            
            const newRequest = request.clone({ setHeaders: { 'Authorization': `Bearer ${token}` }});

            return next.handle(newRequest);


        }else{

            return next.handle(request);
        }

    }