quick question. So this is the code:
export const downloadImage = async (state) => {
try {
let response = await axios.get(state.url, {
responseType: "blob",
});
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement("a");
link.href = url;
link.setAttribute("download", state.url.slice(18));
document.body.appendChild(link);
link.click();
} catch (err) {
console.log(err);
}
};
EDIT: Don't mind the slicing in the setAttribute and the state gives me the full info about the pic, url, text etc.
It works prefectly, when i click download it downloads the img.
Since im using react when i do npm start it starts the live server and when i try to connect to it through my phone (which is on the same wifi network), and i connect with my IPv4 address and react port number (Example: 182.1281.12:3000) the image wont download...
So even tho the code is the same, it works on my PC and won't on my Phone, why is that?
Thanks.