Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

189
Vistas
Vue.js how to have Axios GET and POST request every 5 minutes

I'm trying to have an Axios GET request to be called every 5 minutes, in my .then on the Axios GET request I parse the data and then POST it in a nested Axios request. The POST request though is being triggered before the 5-minute mark. I've tried having them as two separate setIntervals but that hasn't worked for me either. Does anyone have any suggestions and know why the POST is being triggered before the 5 minutes is up.

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);
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda