I'm attempting to retrieve a random quote from an API by generating a random index. However, when I click on the button associated with the index, I am not receiving a random quote as expected. Despite not encountering any obvious errors, the issue persists.
randomQuote() {
const index = Math.floor(Math.random() * this.quotes.length);
return this.quotes[index]
},
Below is the structure of my data object:
data: {
data: [],
quotes: [],
currentIndex: 0,
currentPage: 1,
},
Here is how I am making the API call using axios:
axios.get(url).then(res => {
this.data = res.data;
this.quotes = this.data;
});