undefined is not iterable (cannot read property Symbol(Symbol.iterator))

Discussão em 'Angular' iniciado por Sasini Dissanayake, Novembro 25, 2024.

  1. I'm trying to loop through a fileList in order to perform a delete query. First i fetched data from table "files" in database where attribute "postnumber"=user input. Then it is saved into the "fileList:Files[]". Then a loop through this fileList in order to perform a delete query. but it keeps saying that


    "ERROR TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))". See this image =>
    ​

    [​IMG]

    forum-admin-list.component.ts

    import { FileService } from 'src/app/shared/file.service';
    import { Files } from 'src/app/shared/files.model';
    export class ForumAdminListComponent {
    fileList:Files[];
    onDelete(pNo:string){
    this.fservice.getPost(pNo).subscribe(actionArray => {
    this.fileList = actionArray.map(item => {
    return {
    id: item.payload.doc.id,
    ...item.payload.doc.data()
    } as Files;
    })
    });
    for(let i of this.fileList){
    this.storage.storage.refFromURL(i.path).delete();
    this.firestore.doc("files/"+i.id).delete();
    }
    }
    }


    files.model.ts

    export class Files {
    id:string;
    pNo:string;
    downloadURL:string;
    path:string;
    }


    file.service.ts

    export class FileService {
    formData: Files;
    constructor(private firestore: AngularFirestore) { }

    getPost(userRef){
    return this.firestore.collection('files',ref=>ref.where('pNo','==',userRef)).snapshotChanges();
    }
    }

    Continue reading...

Compartilhe esta Página