Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!