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

780
Views
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 answers
Answer question

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 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!