Skip to content

Execute should return a promise or you should expose a refresh method #25

Open
@fabn

Description

@fabn

I'm having a problem with this scenario:

  • Load recaptcha
  • Load token <ReCaptcha ref={ref => recaptcha = ref} sitekey={siteKey} action='checkout' verifyCallback={filled}/>
  • Submit form with token, captcha validation is ok but some business data are wrong => form shows errors
  • User correct data and resubmit => captcha is reused

I'm having some trouble to get a new token with current interface. I'd like to use something

this.recaptcha.execute()
  .then(token => /* set new token on request */)
  .then(() => api.post(/* new data and new token*/))

or simply a new method that refresh the token with a promise something like

this.recaptcha.refresh() // verify is called again when promise is fulfilled
  .then(() => api.post(/* new data */)) // using the refreshed token

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions