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

219
Views
Resolve Promise after child emits event (Vue)

So the user makes a request for some data but its prompted with a captcha challenge beforehand... when the challenge is resolved, the captcha component emits an event with a token that needs to go in the request.

My question is: can I use a promise to wait for the challenge to be resolved and then make the request with the token? Can I listen to a child component event like this and then resolve the promise?

If this is not the correct way to handle such situation could anyone point me in the right direction? Thanks!

I can listen to the child component event with a v-on:verified but I want to trigger the challenge when making the request and then continue with it after the captcha is resolved by the user.

//component.ts
import captchaComponent from '...';


function executeCaptchaChallenge(){

    // executes challenge on child component via boolean prop
    this.runChallenge = true;

    return new Promise(resolve => {

    //listen to child component event then resolve promise with token emitted (example)
    child.$on('verified', token => {resolve(token)}
})
}


function async getData(){

    const token = await this.executeCaptchaChallenge();
    const response = await axios.post(URL, token);
}
///component.vue

<template>
    <div>
        <button @click="getData">GET DATA</button>
        <captchaComponent @verified="(token) => console.log(token)" />
    </div>
</template>

<script src="component.ts"></script>
about 4 years ago · Juan Pablo Isaza
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!