I want to save the svg file provided by the server as a png file with JavaScript. I think the file format is wrong, how can I download it?
This is the code to download the svg file. I wonder how to fix it.
const accessCookie = getAccessTokenCookie();
axios({
url: `${baseUrl}/${this.Qrid}`,
method: 'GET',
// responseType: 'arraybuffer',
headers: {
Authorization: `Bearer` + accessCookie,
},
}).then(response => {
var file = new Blob([response.data], { type: 'image/svg' });
const fileURL = URL.createObjectURL(file);
const link = document.createElement('a');
link.href = fileURL;
link.download = 'qr' + this.$date().format('YYYY.MM.DD_h_m_s') + '.svg';
link.click();
console.log(response);
});