mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2026-01-08 00:34:25 +01:00
10 lines
416 B
TypeScript
10 lines
416 B
TypeScript
// https://stackoverflow.com/questions/34156282/how-do-i-save-json-to-local-text-file
|
|
|
|
export function downloadTextFile(content: string, fileName: string, type: string) {
|
|
const contentType = type ? type : "application/json";
|
|
const a = document.createElement("a");
|
|
const file = new Blob([content], { type: contentType });
|
|
a.href = URL.createObjectURL(file);
|
|
a.download = fileName;
|
|
a.click();
|
|
} |