Issue with Fetch Request in a TypeScript react app

I am developing a react app and encountering an issue with a fetch request in my TypeScript file. The app is supposed to send a POST request to a Flask server running on localhost:5000. However, when I include the fetch request within a try-catch block inside a method of a class, the extension’s webpage fails to render any elements, and there are no errors logged in the console.

Here is the relevant code snippet, showing the location of the method within the class:



import fetch from 'node-fetch';

class InfoProvider implements Disposable {
  // Other class properties and methods...

  private async sendProofState(proofState: string) {
    try {
      const response = await fetch('http://localhost:5000/api/generate_tactics', {
        method: 'POST',
        headers: {
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({ proof_state: proofState })
      });
      const data = await response.json();
      console.log("Response from Flask server:", data);
    } catch (error) {
      console.error("Error sending data to Flask server:", error);
    }
  }
//other methods
}

The issue seems to be specifically related to the fetch request, as commenting out this block allows the webpage to render correctly. I have confirmed that CORS is enabled on the server, and the server is running without issues.I even commented the line where the function is called and the issue persisted.