Estoy tratando de recibir una solicitud GET de Axios cada 5 minutos, en mi .luego, en la solicitud GET de Axios, analizo los datos y luego los POSTO en una solicitud Axios anidada. Sin embargo, la solicitud POST se activa antes de la marca de 5 minutos. Intenté tenerlos como dos setIntervals separados, pero tampoco funcionó para mí. ¿Alguien tiene alguna sugerencia y sabe por qué se activa el POST antes de que transcurran los 5 minutos?
setInterval(() => { let uri = 'https://prices.runescape.wiki/api/v1/osrs/5m' axios.get(uri).then(response => { console.log(response.data) this.prices = response.data.data; this.timestamp = response.data.timestamp for(const index in this.prices){ this.fiveMinPrice = { "id": index, "avgHighPrice": this.prices[index].avgHighPrice, "avgLowPrice": this.prices[index].avgLowPrice, "highPriceVolume": this.prices[index].highPriceVolume, "lowPriceVolume": this.prices[index].lowPriceVolume, "timestamp": this.timestamp } this.fiveMinPrices.push(this.fiveMinPrice) } let url = '/api/5m/' axios.post(url, this.fiveMinPrices).then(response => { console.log(response) }).catch(function(error){ console.log(error) }) }).catch(function(error){ console.log(error) }) this.fiveMinPrices = [] this.prices = [] this.fiveMinPrice = {} this.timestamp = 0 }, 300000);