1👍
✅
The error is due to the context binding. You can use Arrow function as they have no this
property of their own (They rely on their parent function’s this
property).
Change return new Promise(function(resolve) {..
to return new Promise((resolve) => {..
2👍
Use arrow function when instanciating your promise:
return new Promise((resolve) => { /* ... */ });
👤Faly
1👍
Try to create a var before the promise like:
var self = this;
then use self instead of this inside the promise
Source:stackexchange.com