ERROR TypeError: Failed to execute 'readAsText' on 'FileReader' angular with capacitor...

Discussão em 'Angular' iniciado por Jarich, Setembro 23, 2024.

  1. Jarich

    Jarich Guest

    I have a problem on the FileReader. Currently, I have an angular app and applied a capacitor (Ionic) to It. On my angular app, I integrated an NSWAG to it. Its perfectly working on chrome.

    When running the app on android studio, there is an error on the post API.


    Msg: ERROR TypeError: Failed to execute 'readAsText' on 'FileReader': parameter 1 is not of type 'Blob'. This is the code from web.api.client.ts
    ​

    function blobToText(blob: any): Observable<string> {
    return new Observable<string>((observer: any) => {
    if (!blob) {
    observer.next("");
    observer.complete();
    } else {
    let reader = new FileReader();
    reader.onload = event => {
    observer.next((event.target as any).result);
    observer.complete();
    };
    reader.readAsText(blob);
    }
    }); }


    For the capacitor.config.ts, not sure If I need to add some codes to it.

    import type { CapacitorConfig } from '@capacitor/cli';

    const config: CapacitorConfig = {
    appId: 'com.myapp.app',
    appName: 'MyApp App',
    webDir: 'dist',
    bundledWebRuntime: false,
    server: {
    cleartext: true,
    },
    plugins: {
    CapacitorHttp: {
    enabled: true,
    },
    }
    };

    export default config;


    I made some research but the solutions doesn't work. The above codes are working on my Angular project.

    Continue reading...

Compartilhe esta Página