I am using a library that has the following definition in the d.ts file.
export function read(success?: (data: any, response: Response) => void);
I have the following class which works fine if the method is called with an Arrow function.
export class App {
private async getData(): Promise<void> {
lib.read((data, response) => {
console.log(data);
});
}
}
However, if I try to pull the method into a class method, it does not work. When I step into the read method of library, it says that it is undefined.
export class App {
private async onSuccess(data, response) {
console.log(data);
}
private async getData(): Promise<void> {
lib.read(this.onSuccess)
}
}
Any ideas why? Thanks!