1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

How can I test that this public PDF exists in Angular?

Discussão em 'Angular' iniciado por Flyout91, Junho 18, 2025.

  1. Flyout91

    Flyout91 Guest

    In Angular 18, I want to return true or false whether a public PDF exist or not. For example, it should return true for : https://sigesbre.brgm.fr/files/fiches/MDO_AgenceEau/MDO_AgenceEau_FRGG015.pdf

    My code is the following, but I land in catchError instead of map :

    existFile(path: string): Observable<boolean> {
    return this.httpClient.get(path, { responseType: 'blob' }).pipe(
    map(() => {
    console.log('exists', path);
    return true;
    }),
    catchError((e) => {
    console.log('does not exist', e);
    return of(false);
    })
    );
    }


    The error logged in console is : [​IMG]

    Continue reading...

Compartilhe esta Página