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

126
Visualizações
What is really happening in this Typescript code. Having result is wrong with the hardcode string and parameterized string

I have a method to do some typeorm actions on an entity.

  async deactivateBarcode(barcode: string) {
let currentBarcode: Barcode = await this.barcodeRepository.findOne({
  code: barcode,
});

currentBarcode.isActive = true;

return await this.barcodeRepository.save(currentBarcode);

}

this prints an error message for the line "currentBarcode.isActive'

TypeError: Cannot set property 'isActive' of undefined

but when I hard code the barcode value in to the { code: 'hardcodebarcode'}, the line 'currentBarcode.isActive' has value and it works..

 async deactivateBarcode(barcode: string) {
let currentBarcode: Barcode = await this.barcodeRepository.findOne({
  code: '3sfsdfsderer',
});

currentBarcode.isActive = true;

return await this.barcodeRepository.save(currentBarcode);

}

My question, what is happening in this method which is causing this different behavior that 'when passed as parameter' or 'when hardcoded the same value'..

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