How to access class variable inside Promise then() function?

 https://stackoverflow.com/questions/48064389/how-to-access-class-variable-inside-promise-then-function

If you pass a function reference, this won't point to the local class instance anymore.

You can use bind

.then(this.extractData.bind(this))

or arrow functions

.then((res) => this.extractData(res))

to get the desired behavior.

Không có nhận xét nào:

Cold Turkey Blocker

 https://superuser.com/questions/1366153/how-to-get-rid-of-cold-turkey-website-blocker-get-around-the-block Very old question, but still wan...