@zodash/down_load
Version:
Download File in Browser
16 lines • 687 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.download = void 0;
const save_as_1 = require("@zodash/save-as");
async function download(url, filename = `${Date.now()}`, options) {
const response = await fetch(url, {
method: options === null || options === void 0 ? void 0 : options.method,
headers: options === null || options === void 0 ? void 0 : options.headers,
body: options === null || options === void 0 ? void 0 : options.body,
});
const blob = await response.blob();
return save_as_1.saveAs(blob, filename);
}
exports.download = download;
exports.default = download;
//# sourceMappingURL=index.js.map