Hello I got The following form where I got a onClick button storing Data in a List. Following on script I call axios and creating methods, So when I press Submit Values are stored in my List. Now my problem is how can I make my Button automatically hit endpoint every 1 minute , so when I refresh my List after 60 minutes , it would contain 60 values inside. And then I want to add first 5 values of list so I find the average values of first 5 minutes
//eslint-disable-next-line no-unused-vars
import axios from 'axios'
export default {
data() {
return {
apiEndPoint: 'https://api.coinbase.com/v2/prices/spot?currency=',
apiData: [],
amountList: [],
}
},
created() {
this.getData(this.currency);
},
methods: {
getShortList(shortListSize) {
return this.amountList.slice(0, shortListSize);
},
},
getData(currency) {
axios.get(`${this.apiEndPoint}${currency}`)
.then((response) => {
for (let i = 0; i < 59; i++) {
this.apiData = response.data
this.amountList.push(response.data.data.amount)
console.log(response.data.data.amount)
}
})
}
}
<form>
<label>Enter Currency: <input type="text" v-model="currency"></label>
<input id="clickMe" type="button" value="Submit" @click="getData(currency)" />
</form>