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

218
Visualizações
Uncaught (in promise) TypeError: Cannot set properties of undefined

So I'm using vue 2 for a project and I need to update an array that I named storychosen with the number of tests passed,failed and skipped for each story (I have a collection of tests that are grouped by story name) this is the method that I use to get that)

 getstoryresult(storyname) {
        const res=axios({
        method: "post",
        url: "http://localhost:3002/backend/storytests",
        data: {
          stname: storyname

        },
      }).then(function(result){
        console.log(result.data.data)
        var storypass=0
        var storyfail=0
        var storyskip=0
        for (let i in result.data.data){
          switch(result.data.data[i].status)
          {
            case 'passed':storypass++;break;
            case 'skipped':storyskip++;break;
            case 'failed':storyfail++;break;
          }
         
          
        }
        console.log(storypass,storyfail,storyskip)
         this.storychosen= [storypass, storyfail, storyskip] //storychosen is declared in data as an empty array
      })
        
      }

the post request return an array of tests and I just iterate over these tests and get the status of each test and increment one of the 3 status variables.

my problem is when i try to update the storychosen variable i get the error Uncaught (in promise) TypeError: Cannot set properties of undefined.I'm not used to working with promises so it might be a stupid question but how can I update the storychosen array in the .then function

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