basic changing Angular data service url for API calls

31 Views Asked by At

I have an Angular dataService that uses its own hostname to make the API calls because in production, the API lives on the same host, but for local testing I need to use a different port number.

So for this class:

...
@Injectable()
export class DataService() {

    constructor(private http: HttpClient) {}

    apiRelativePath: string = 'api';
    
    applicationValue = {
        getAppInfo: () Observable<AppInfoDto> => this.http.get<AppInfoDto>(`${this.apiRelativePath}/AppInfo`).pipe(map(value => new AppInfo(value))).pipe(catchError(this.handleError))};
    }

}

I need to change the hostname of the URL just for local development. Say to something like "http://localhost:4444" or something like that. I don't even need to change the protocol if I can just change the port.

How do I do that ?

0

There are 0 best solutions below