export default class CustomPromise extends XMLHttpRequest {
constructor(url: string, type: string) {
super();
config.url = url;
config.requestType = type;
}
}
In this code snippet, a custom promise class is created by extending the XMLHttpRequest
.
An instance of this class is then attempted to be created as shown below.
let customProm = new CustomPromise('api/200', 'get');
However, upon calling the super method, the following error was encountered:
Failed to construct 'XMLHttpRequest': Please use the 'new' operator, this DOM object constructor cannot be called as a function