3👍
✅
That’s because the context inside the callback is different:
callback: function(data) {
console.log(this); // you will see registerPayment doesnt exist here
this.registerPayment(data);
},
Why not use the registerPayment
directly? You can do so with:
callback: this.registerPayment
If you still want to call registerPayment
from within the callback
you can use arrow functions to access the outside context:
callback: (data) => {
this.registerPayment(data);
}
Source:stackexchange.com