162
rated 0 times
[
164]
[
2]
/ answers: 1 / hits: 22169
/ 8 Years ago, tue, november 1, 2016, 12:00:00
I am trying to set a variable declared at the beginning of the class (a boolean) to true once a callback is called, but I keep getting a TypeScript erorr.
Here is the error:
TypeError: Cannot set property 'nonReceived' of undefined
Here is my code:
finalizeToken(){
braintree.setup(JSON.parse(this.finalToken), 'dropin', {
container: 'dropin-container',
defaultFirst: true,
form: 'checkout-form',
onPaymentMethodReceived: function (obj) {
this.nonReceived = true;
localStorage.setItem('nonce', obj.nonce);
}
});
}
The brintree-setup connect to Braintree Payments, and awaits user payment info. Once they submit the form, I need the variable this.nonReceived to be set to true.
More From » typescript