In my TypeScript application I make use of Promise<void>
, which is stored within a local class-wide variable. It is possible that some method of the same class is called which then waits on this promise to get resolved or rejected, but this does not always happen. It is very possible that the promise is started without anybody listening to it. When nobody is listening to the promise, I get the following error in the console:
Uncaught (in promise) undefined
The job contained within the promise runs trough successfully without problems. It is just this error message that I would like to be sure about its meaning. Am I right to assume that this error message just means that nobody is listening to the resolve or reject of the promise, hence, it just does its job by its own? Is there anyway to suppress this error message?
The promise looks like this:
private apiInitialization: Promise<void>;
...
this.apiInitialization = new Promise<void>((resolve, reject) => {
this.siteService.requestInitialization().then((response: RequestResponse) => {
// Do some stuff.
// Resolve promise.
resolve();
}).catch(() => {
// Reject promise.
reject();
});
});