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?