after setup a simple image upload i've tried to call another function from a function and the logs spits out
Unhandled Rejection (TypeError): self.sendImage is not a function
here is the code
readFile(files) {
var self = this;
if (files && files[0]) {
let formPayLoad = new FormData();
formPayLoad.append("attachment_image", files[0]);
self.sendImage(formPayLoad);
}
}
sendImage(formPayLoad) {
let auth_token = window.localStorage.getItem("auth_token");
fetch("/posts", {
headers: {
Accept: "application/json",
Access: auth_token
},
method: "POST",
body: formPayLoad
})
.then(response => response.json())
}
To fix it i've tried to change the variable this to self and still persist the error.
so, please, can someone clarify why this Unhandles Rejecton? is related to class Es6?