Dont know how to send image through request as base64 string to store it as blob object in sqlite FastAPI framework and has no idea about which method to use, using formdata or ??? is there any method to do above mentioned task
var pimagefile = document.getElementById("pImage").files[0];
var pimageblob = new Blob([pimagefile],{type: 'image/jpg'});
function convertToBase64(){
var pimageBase64 = // convert to base64 string
}
var toSend = {
pimage: pimageBase64
}
var jsonString = JSON.stringify(toSend);
var xhttp = new XMLHttpRequest();
xhttp.open("POST", "http://127.0.0.1:8000/products/add/", true);
xhttp.setRequestHeader("Content-Type", "application/json");
xhttp.send(jsonString);