Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

794
Vistas
How to implement 'one-time-code' in interval function?

Let's say I have a function - checker - on front-end which works every 10 seconds.

async check() {
  this.globalLoader = true
  const result = await finalizePayment({
    id: this.id ? this.id : undefined,
    paymentId: this.paymentId ? this.paymentId : undefined,
    token: localStorage.getItem('token'),
  })
  this.globalLoader = false

This function returns transaction status, and if it's done, I implement my Google Analytics code:

  if (result.status === 'done') {
      ...
  }

But there is a problem, I need to implement this GA code only one time, when transaction is done. If user reloads page, this check() function will return result.status === 'done' and my GA code will run again, but I don't need that again, because I have already made GA record about transaction.

So, how can I make it? I was thinking about localStorage value, but what if user removes this value from local storage?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you want an alternative to localStorage then I suggest you to go with vue-persist

https://www.npmjs.com/package/vuex-persist

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda