Having a SetInterval embedded within a Promise in Axios is causing an error when trying to run a function inside the SetInterval block. The specific error encountered is:
methods: {
getJson() {
axios.post(url, FormObject, config)
.then(response => {
var searchId = JSON.stringify(response.data.searchId)
this.sendStatus(searchId)
var status = setInterval(function(){ this.sendStatus(searchId) },
30000);
})
.catch(err => (this.error = err))
},
sendStatus(searchId){},
}
The initial call to 'sendStatus' function works as expected. However, the setInterval operation results in the following error message:
Uncaught TypeError: this.sendStatus is not a function at eval