0

I am receiving a string that I thought was an image blob, but I am unable to transform it into a valid URL. I am not sure how to do it correctly. Can someone help me?

request $.ajax(payload, () => const blob = new Blob([response], { type: "image/*"});
const url = URL.createObjectURL(blob);
const testData = {...data};
delete testData.src;
testData.src = url; 
setNewData(testData);

The response is an image.

  • You have to request the data as a blob or array buffer, similar https://stackoverflow.com/questions/17657184/using-jquerys-ajax-method-to-retrieve-images-as-a-blob – Musa Jun 23 '23 at 12:48

0 Answers0