mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2025-12-27 10:54:21 +01:00
15 lines
432 B
TypeScript
15 lines
432 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();
|
|
}
|