3👍
You are changing the context of this
in your second call, as you are introducing a new function.
If you are using ES6, the easiest way to overcome this, is to use an arrow function instead of the function keyword.
var status = setInterval(() => { this.sendStatus(searchId) },
30000);
})
If you cannot use ES6, you have to use the .bind()
function, which is explained in this question. Easier, but dirtier would be to reassign this
to a local variable.
var that = this;
Then use that.sendStatus
in your callback function.
1👍
You need to use an arrow function in your setInterval
, like this :
setInterval(() => this.sendStatus(searchId))
Here is a resource explaining more the arrow functions and this
Source:stackexchange.com