Ionic photo gallery code not working

I am going over the photo gallery ionic app tutorial. I am at the part in which I am able to take photos, store them and when the page is refreshed, reload them. The problem is that when refreshing the page, the photo is not loaded. The picture blinks and goes away.

Here is the basic code


import { Injectable } from '@angular/core';
import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera';
import { Filesystem, Directory } from '@capacitor/filesystem';
import { Storage } from '@capacitor/storage';
  providedIn: 'root'
export class PhotoService {

  public photos: UserPhoto[] = [];
  private PHOTO_STORAGE: string = 'photo';
  constructor() { }
  private async savePicture(photo: Photo){
    const base64Data = await this.readAsBase64(photo);
    const fileName = new Date().getTime() + '.jpeg';
    const savedFile = await Filesystem.writeFile({
        path: fileName,
        data: base64Data,
        directory: Directory.Data

      filepath: fileName,
      webviewPath: photo.webPath
  private async readAsBase64(photo: Photo){
    const response = await fetch(photo.webPath!);
    const blob = await response.blob();

    return await this.convertBlobToBase64(blob) as string;

  private convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
    const reader = new FileReader;
    reader.onerror = reject;
    reader.onload = () => {

  public async addNewToGallery(){
    const capturedPhoto = await Camera.getPhoto({
      resultType: CameraResultType.Uri,
      source: CameraSource.Camera,
      quality: 100

    const savedImageFile = await this.savePicture(capturedPhoto);;
      key: this.PHOTO_STORAGE,
      value: JSON.stringify(,

  public async loadSaved(){
    const photoList = await Storage.get({key: this.PHOTO_STORAGE}); = JSON.parse(photoList.value) || [];
    for(let photo of{
       const readFile = await Filesystem.readFile({
          path: photo.filepath,
          directory: Directory.Data
       photo.webviewPath = 'data:image/jpeg;base64, ${}';

export interface UserPhoto {
  filepath: string;
  webviewPath: string;

import { Component } from '@angular/core';
import { PhotoService } from '../services/photo.service';

  selector: 'app-tab2',
  templateUrl: '',
  styleUrls: ['']
export class Tab2Page {

  constructor(public photoService: PhotoService) { }

  async ngOnInit(){
    await this.photoService.loadSaved();



<ion-header [translucent]="true">
      Photo Gallery

<ion-content [fullscreen]="true">
  <ion-fab vertical="bottom" horizontal="center" slot="fixed">
    <ion-fab-button (click)="addPhotoToGallery()">
      <ion-icon name="camera"></ion-icon>
       <ion-col size="6" *ngFor="let photo of; index as position">
          <ion-img [src]="photo.webviewPath"></ion-img>
  <app-explore-container name="Tab 2 page"></app-explore-container>

Do you have any errors that appear in your console?

Failed to load resource: net::ERR_FILE_NOT_FOUND
Failed to load resource: net::ERR_INVALID_URL

how to solve this.Is there any ideas plz
share me