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

105
Visualizações
Promise error when on variable that takes boolean value

I have this constructor:

constructor(props: Props) {
    super(props);
    this.loggingService = new LoggingService();
    this.state = {
      disableButton: this.reissueService.getReissueStatus(props.policy),
      showReissuePrompt: false
    };
}

disableButton is disableButton: boolean.

This is my getReissueStatus:

async getReissueStatus(policy: string): Promise<boolean> {
    return await ApiService.getData(this.apiUrl + policy + this.myEndpoint).then(
        (response) => response.data
    );
}

I have this error on disableButton in the constructor:

Type 'Promise<boolean>' is not assignable to type 'boolean'.ts(2322)
Disclaimer.tsx(18, 4): The expected type comes from property 'disableButton' which is declared here on type 'Readonly<State>'

If Promise<boolean> and boolean aren't compatible and also, the constructor can't be asynchronous, how do I resolve this so that disableButton is assigned a boolean value that is returned by the API call in getReissueStatus?

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