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

176
Views
Generate random data in vue

I'm trying to generate a random quote from data obtained through an api. I generated a random index but when I click on the corresponding button I'm not getting back a random quote. I'm not getting any apparent errors.

randomQuote() {
    const index = Math.floor(Math.random() * this.quotes.length);
    return this.quotes[index]
  },

Here's my data object.

data: {
    data: [],
    quotes: [],
    currentIndex: 0,
    currentPage: 1,
  },

Here's my axios call:

axios.get(url).then(res => {
        this.data = res.data;
        this.quotes = this.data;
      });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There is an apparent error in your axios call, you are not setting quotes to the correct object:

axios.get(url).then(res => {
  this.quotes = res.data.quotes;
});
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!