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

89
Views
cómo hacer que la llamada vue firebase sea asíncrona

Estoy usando Amazon Mechanical Turk para contratar a algunos trabajadores. Estoy usando vue con firebase. En firebase tengo los hits (mturk) y quiero cerrar el hit cuando el formulario se envía en mturk iframe. El problema es que a veces cierra el hit y a veces no.

 public async submitAssignment() { var urlParams = new URLSearchParams(window.location.search) if (urlParams.has('assignment_id')) { this.host = urlParams.get('host') this.assignmentId = urlParams.get('assignment_id') this.workerId = urlParams.get('workerId') this.hitId = urlParams.get('hitId') const oFormObject = document.forms['mturkForm'] oFormObject.action = this.host oFormObject.elements['assignmentId'].value = this.assignmentId oFormObject.elements['workerId'].value = this.workerId oFormObject.elements['hitId'].value = this.hitId // form is not waiting for this before submitting the form await this.$store.dispatch('hits/closeHit', { hitId: this.hitId, workerId: this.workerId }) oFormObject.submit() }

}

acción Vuex

 const actions = { async closeHit({}, payload: any) { await db.hits .setDone(payload) .then() .catch((error) => { console.log(error) }) } }

hits.ts

 async setDone(payload: any) { try { return firestore.db .collection(collectionNamespace) .doc(payload.hitId) .update({ open: false, workerId: payload.workerId }) } catch (error) { console.error('Error updating document: ', error) } }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puedes usar la siguiente sintaxis

 await this.$store.dispatch('hits/closeHit', { hitId: this.hitId, workerId: this.workerId }).then(() => { oFormObject.submit() })
about 4 years ago · Juan Pablo Isaza Report

0

No estoy seguro de si causa su problema actual, pero este código parece un antipatrón:

 const actions = { async closeHit({}, payload: any) { await db.hits .setDone(payload) .then() .catch((error) => { console.log(error) }) } }

Debe await then o await , no ambos. En este momento, su then no hace nada, pero puede estar rompiendo la await .

Más simple y con más probabilidades de ser correcto:

 const actions = { async closeHit({}, payload: any) { await db.hits .setDone(payload) } }
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!