auth.service.ts:56
err HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: "https://192.168.254.115:7047/api/Auth/login"
zone.js:2680
POST https://192.168.254.115:7047/api/Auth/login net::ERR_CERT_AUTHORITY_INVALID
login(username: string, password: string): Observable {
this.isLoadingSubject.next(true);
return this.authHttpService.login(username, password).pipe(
map((auth: AuthModel) => {
const result = this.setAuthFromLocalStorage(auth);
return result;
}),
switchMap(() => this.getUserByToken()),
catchError((err) => {
console.error('err', err);
return of(undefined);
}),
finalize(() => this.isLoadingSubject.next(false))
);
}
authToken
here? ${API_USERS_URL}/login
request. Does it return all AuthModel
fields? (src/app/modules/auth/models/auth.model.ts)${API_USERS_URL}/login
returns an error in console:
HttpErrorResponse {
headers: HttpHeaders, status: 200, statusText: 'OK', url: 'https://apiUrl/login', ok: false, ..}
error: { error: SyntaxError: Unexpecdted token e in JSON at position 0 at JSON.parse () at XMLHttpRequest.onLoad (http://localhost:4200/vendos.js:28559:39) at _ZoneDelegate.invokeTask ...
stack:
"SyntaxError: Unexpected token e in JSON at position 0
at JSON.parse ()
at XMLHttpRequest.onLoad (http://localhost:4200/vendor.js:28559:39)
at _ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:3521:31)
at Object.onInvokeTask (http://localhost:4200/vendor.js:55129:33)
at _ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:3520:60)
at Zone.runTask (http://localhost:4200/polyfills.js:3293:47)
at ZoneTask.invokeTask [as invoke] (http://localhost:4200/polyfills.js:3602:34)
at invokeTask (http://localhost:4200/polyfills.js:4763:18)
at globalCallback (http://localhost:4200/polyfills.js:4806:33)
at XMLHttpRequest.globalZoneAwareCallback (http://localhost:4200/polyfills.js:4827:16)"
text (this is my token, the api returns correctly for the application): "eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTUxMiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoibGVvIiwiaHR0cDovL3NjaGVtYXMubWljcm9zb2Z0LmNvbS93cy8yMDA4LzA2L2lkZW50aXR5L2NsYWltcy9yb2xl"}
getAuthFromLocalStorage
method. It will help you understand the issue then.