Promises - this.fileLoad.then is not a function

0

Good afternoon.

I'm having this error - this.fileLoad.then is not a function, could someone please explain to me why this is occurring?

fileLoad(){

    return new Promise((resolve, reject) =>{

        let fileReader = new FileReader();

        let fieldFile = [...this.formID].find(element =>{

            if(element.type === "file"){

                return element.files;

            }
        });

        fileReader.onload = () =>{

            fileReader.result;
            resolve(fileReader);
        }

        fileReader.onerror = () =>{

            reject("erro");

        }

        fileReader.readAsDataURL(fieldFile.files[0]);
    }

)};

this.fileLoad.then(    
        (content)=>{
            console.log(content);

        },
        (e)=>{

            console.log(e);

 })
  

Uncaught TypeError: this.fileLoad.then is not a function       at userController.addUser (userController.js: 76)       at userController.loadFiles (userController.js: 57)       at HTMLDocument.document.addEventListener.event (userController.js: 20)

    
asked by anonymous 05.07.2018 / 17:07

1 answer

2

You need to call the function with parentheses, this.fileLoad (). then (...

    
05.07.2018 / 17:11