Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

186
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda