1π
β
You can use arrow function or closure:
var self = this
reader.onload = function () {
var asim = reader.result
formData.append('file', self.file)
let promises = []
promises.push(
performRpcWithPromise('insertContract', [
asim, clientId
]).then(function (res) {
console.log(res)
self.currentStatus = STATUS_SUCCESS
console.log(self.currentStatus)
})
)
}
If you want to use arrow function, please try
reader.onload = () => {
var asim = reader.result
formData.append('file', this.file)
let promises = []
promises.push(
performRpcWithPromise('insertContract', [
asim, clientId
]).then((res) => {
console.log(res)
this.currentStatus = STATUS_SUCCESS
console.log(this.currentStatus)
})
)
}
3π
Try using arrow function instead. Like this:
.then(res => {
console.log(res)
this.currentStatus = STATUS_SUCCESS
console.log(this.currentStatus)
})
I believe itβs similar to this.
Source:stackexchange.com