'Getting a http call to an external service to work in Angular

I am not having issues making calls to my own backend but when I call the following function the HTTP call is not even attempted according to chromedev network tab.

I see the 'Doing httpget' in the console but I don't see the message in the tap or the handleError.

This is for angular 13

public getCapabilities(url:string){
    console.log("Doing httpget")
    this.http.get('https://geo.weather.gc.ca/geomet?lang=en&service=WMS&version=1.3.0&request=GetCapabilities')
    .pipe(
        tap((response) => {console.log(response);debugger;}),
        catchError(err => this.handleError(err)))

}
private handleError(error: HttpErrorResponse) {
    console.log(error)
    debugger;
    if (error.error instanceof ErrorEvent) {
        // A client-side or network error occurred. Handle it accordingly.
        console.error('An error occurred:', error.error.message);
    } else {
        // The backend returned an unsuccessful response code.
        // The response body may contain clues as to what went wrong.
        console.error(
            `Backend returned code ${error.status}, ` +
            `body was: ${error.error}`);
    }
    // Return an observable with a user-facing error message.
    return throwError(
        'Something bad happened; please try again later.');
}


Solution 1:[1]

Might be that your code example is incomplete, but the way it is now, you are missing a subscribe() call after the pipe(...) to trigger the execution.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 slim