I'm trying to read a JSON configuration file like this
this.http.get('assets/env/env.json').pipe(map( res => res.json())).pipe(catchError((error: any): any => {
console.log('Configuration file "env.json" could not be read');
return Observable.throw(error.json().error || 'Server error');
})).subscribe( (envResponse) => {
endpoint="conf-" + envResponse.env + ".json";
alert(endpoint);
});
But res.json() shows as error
I'm importing these classes
import { Injectable } from '@angular/core';
import { HttpClient, HttpBackend } from '@angular/common/http';
import { map, catchError } from 'rxjs/operators';
import { Observable } from 'rxjs';
Could you please suggest what I did wrong?
Mine is angular 9