I am not able to identify the root cause behind error response change. In my local I see following error message.
based on this status code I am writing my logic.
However, in production the error response is completely different
What is it trying to say? How do I fix this?
getScenarioByScenarioId(ID) {
return this.http.get<any>(this.basePath + `scenario/` + ID, {
headers: this.getHeader(),
});
}
getHeader() {
return {
'Content-type': 'application/json',
accept: 'application/json'
}
}
http.interceptor code
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if (request.url.includes('configurations') || request.url.includes('gisMixedContent')) {
return from(this.handleAccess(request, next));
}
return next.handle(request);
}
private async handleAccess(req: HttpRequest<any>, next: HttpHandler): Promise<HttpEvent<any>> {
const getAuthToken = await this.authService.getAuthToken().toPromise();
const changedReq = req.clone({
setHeaders: {
Authorization: `Bearer ${getAuthToken}`
}
});
return next.handle(changedReq).toPromise();
}
}
Why the intermediate promise, why not just return the handle result.
...
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if (request.url.includes('configurations') || request.url.includes('gisMixedContent')) {
return this.handleAccess(request, next);
}
return next.handle(request);
}
private async handleAccess(req: HttpRequest<any>, next: HttpHandler): any {
const getAuthToken = await this.authService.getAuthToken().toPromise();
const changedReq = req.clone({
setHeaders: {
Authorization: `Bearer ${getAuthToken}`
}
});
return next.handle(changedReq);
}
}