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

248
Views
Cómo agregar retraso en una llamada de función en JS/Vue JS ("esto" se vuelve indefinido)
updateGraphCurrentIndex(value) { // Returns a Promise that resolves after "ms" Milliseconds const timer = function(ms) { return new Promise(res => setTimeout(res, ms)); }; this.$vs.loading({ container: "#compare-chart", type: "point" }); console.log("///////selected TAB Recieved", value ,"///////// tickersss", this.selectedTickers); this.current_index = value; // clear data on Graph this.selectedTickers.forEach((ticker) => { this.clearTickerDataGraph(ticker); }); // display data on the table console.log("////////selectedTikerss", this.selectedTickers[0]); async function load() { try { console.log("////////WHAT IS THIS", this); for (let index = 0; index < this.selectedTickers.length; index++) { console.log("Helllo ", index); console.log("////////////i is called here", this.selectedTickers[index]); this.tickerDataGraph(this.selectedTickers[index]); await timer(3000); } } catch (error) { console.log("///////////error in Load", error); } } load(); // this.selectedTickers.forEach((ticker, i) => { // setTimeout(()=> { // this.tickerDataGraph(ticker); // // await timer(3000); // then the created Promise can be awaited // }, 3000); // }); // ['IBM', 'APPL'] // this.selectedTickers.forEach((ticker) => { // this.tickerDataGraph(ticker); // }); }

Quiero que mi método de load se ejecute después 3 seconds , pero a medida que el flujo de ejecución ingresa al método de load , aparece este error Cannot read properties of undefined (reading 'selectedTickers') . En realidad, this queda indefinido dentro del método de load asíncrona. El this.tickerDataGraph(this.selectedTickers[index]) contiene llamadas API que quiero retrasar.

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!