Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

331
Views
this.$refs.upload.submit(); not returning response Element-UI

I'm using element-ui and I'm uploading a file with:

this.$refs.upload.submit();

How can I get the reponse from this.$refs.upload.submit();?

I already tried:

.then(response => {
    this.success = true;
})
.catch(errors => {
    if(errors.status === 422 && this.hasError('Exists')) {
        this.Link= true;
    }
    this.success = false;
})

I know the submit() needs some sort of promise. I just don't know what to change, I just want to get the error messages.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I am not to familiar with element-ui but custom components almost always have events that trigger when certain functions finish.

In this case looking at the documentation: https://element.eleme.io/#/en-US/component/upload#upload What you need is on-success or on-error.

So you just have to add functions to your el-upload component:

<el-upload
   :on-error="onError"
   :on-success="onSuccess">

And add the methods to your methods object in vue:

methods: {
      submitUpload() {
        this.$refs.upload.submit();
      },
      onError(){
        console.log("error");
      },onSuccess(){
        console.log("success");
      }
}

An example would be: https://codepen.io/Freshdachs/pen/LYjWpZo

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!