How do you set the name of a blob file in JavaScript when force downloading it through window.location
?
function newFile(data) {
var json = J
This is my solution. From my point of view, you can not bypass the .
function export2json() {
const data = {
a: '111',
b: '222',
c: '333'
};
const a = document.createElement("a");
a.href = URL.createObjectURL(
new Blob([JSON.stringify(data, null, 2)], {
type: "application/json"
})
);
a.setAttribute("download", "data.json");
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}