I'm new to JavaScript, I'm wondering why the following throws an error in validateThisScenario
and what I can do to make it work in a similar structure.
class TestClass {
// ...
getResponse() {
return this._response
}
validateThisScenario() {
const response = this.getResponse() // TypeError: Cannot read property 'getResponse' of undefined
}
test1() {
return this.test(this.validateThisScenario)
}
test(validation) {
return Promise.resolve()
.then(() => validation())
.catch((err => {
// ...
}))
}
}