0

I'm trying to implement an autosave feature, where every 10 minutes it calls the save function. However if I use setInterval() it throws an error, stating this.createMapXML is not a function. But if I call the save function manually (e.g. by pressing a button) it works.

The code:

startautoSave(){setInterval(this.uploadToDataBase, 600000)};

uploadToDataBase(){
    this.toUploadMap.xml = this.createMapXML();
.
.
.
}
createMapXML(): string {. . .}
Zerox
  • 290
  • 4
  • 18
  • 1
    `setInterval(this.uploadToDataBase, 600000)` -> `setInterval(() => this.uploadToDataBase(), 600000)` – VLAZ Oct 18 '21 at 07:49
  • 1
    Also relevant: [Pass correct "this" context to setTimeout callback?](https://stackoverflow.com/q/2130241) – VLAZ Oct 18 '21 at 07:49

0 Answers0