1
0
Fork 0
mirror of synced 2024-09-19 02:39:37 +12:00
budibase/packages/frontend-core/src/utils/download.js

14 lines
346 B
JavaScript
Raw Normal View History

export function downloadText(filename, text) {
if (typeof text === "object") {
text = JSON.stringify(text)
}
const blob = new Blob([text], { type: "plain/text" })
const url = URL.createObjectURL(blob)
const link = document.createElement("a")
link.href = url
link.download = filename
link.click()
URL.revokeObjectURL(url)
}