sendData = () => {
let data = new FormData();
let res = await makeRequest(file);
data.append('photo', res);
await axios.post( api.url ).then(response => {
console.log( response.data ) ;
}).catch((error) => {
throw new Error(error.response.data);
});
}
makeRequest = async (url) => {
return new Promise(function (resolve, reject) {
let xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.responseType = "blob";
xhr.onload = () => {
resolve(xhr.response);
};
xhr.send();
});
}