Hi all,
i would like how to resolve this problem:
After a http request with promise, the callback value “this” is undefined…
How can i resolve this?!
Here the callback:
Here the internal request:
Thanks for help,
Andrea
Hi all,
i would like how to resolve this problem:
After a http request with promise, the callback value “this” is undefined…
How can i resolve this?!
Here the callback:
Here the internal request:
Thanks for help,
Andrea
From your code, something weird happen, and this
should be the same with that
. But it doesn’t seem to be the case. I think it’s maybe debugger behavior, showing you wrong information?
It can be an error of debugger, but the if condition “this.ticketType != this.ticketModel.type” ( Under the tooltip" is alwyas undefined !?!
and “this” is undefined too as “that”
Then probably that
in that function is referring to lexical scope. Can you show full code of that function that invokes updateTicket
?
Maybe put a debugger, and go to browser dev tool and check what the after transpiled code looks like, I suspect something got wrong during that phase. The source looks pretty normal to me
i read this:
but i m not able to understand how to resolve my problem.
The way onUpdateTicket
is declared and how you are passing arrow function to .then
guard against what you saw in that question I believe. I think unless you can provide a reproduction or get help from someone who has experienced this before, it’s gonna be a tough one.
I had the same problem. I’ve changed this:
Promise.resolve()
.then(this.method)
by this:
Promise.resolve()
.then(() => this.method())
and problem was solved.