There is a boolean variable disableButton: boolean;
that needs to be set based on the response received from this API call:
async getDocStatus(policy: string): Promise<boolean> {
return await ApiService.getData(this.apiUrl + policy + this.myEndpoint).then(
(response) => response.data
);
}
The intention is to execute this logic when the page loads, so the call has been added to the componentDidMount
method:
componentDidMount() {
const queryString = require('query-string');
const parsed = queryString.parse(location.search);
return this.reissueCertService.getDocStatus(parsed.pol).then(response => {
this.setState({disableButton: response});
}).catch((error) => {
this.loggingService.logError('Error returning Docs ' + error);
});
}
However, upon loading the page, an error occurs and it's unclear how to resolve it. Can anyone provide guidance?
TypeError: Cannot read properties of undefined (reading 'getDocStatus') CertificateDisclaimer../src/components/certificate/Certificate.tsx.Certificate.componentDidMount C:/git/ui.myui/src/components/certificate/Certificate.tsx:38 ... This screen is visible only in development. It will not appear if the app crashes in production. Open your browser’s developer console to further inspect this error.
This is the component class structure:
import * as React from 'react';
import './Certificate.css';
...
[Code snippet continues...]