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

Angular 16: trying to read file from the project

Discussão em 'Angular' iniciado por Mark, Julho 28, 2025.

  1. Mark

    Mark Guest

    I want to read my local data into stackblitz project. I have the file to the project and here is the code that trying:

    ngOnInit() {
    this.getFileData()
    .subscribe(response => console.log(response));
    }

    getFileData() {
    return this.http.get('data.txt')
    .pipe(
    switchMap((response: any) => this.http.get(response.pathToFile, {
    responseType: 'text'
    }))
    );
    }


    In the project's console I am getting this: [​IMG]

    What am I doing wrong?

    Continue reading...

Compartilhe esta Página