fastapi-rtk
Version:
A React component library for FastAPI in combination with FastAPI React Toolkit backend, built with Mantine, JsonForms, and Zustand.
40 lines (39 loc) • 1.26 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const utils = require("fastapi-rtk/utils");
const downloadItems = async (path, queryParams, { label, export_mode, delimiter, quotechar } = {}) => {
const _queryParams = { ...queryParams, check_validity: true };
if (label) {
_queryParams.label = label;
}
if (export_mode) {
_queryParams.export_mode = export_mode;
}
if (delimiter) {
_queryParams.delimiter = delimiter;
}
if (quotechar) {
_queryParams.quotechar = quotechar;
}
const { fetchPath: fetchPatchCheck, options: optionsCheck } = utils.createFetchParams({
path: utils.urlJoin(path, "/download"),
method: "GET",
queryParams: _queryParams
});
const response = await fetch(fetchPatchCheck, optionsCheck);
await utils.parseResponse(response);
delete _queryParams.check_validity;
const { fetchPath } = utils.createFetchParams({
path: utils.urlJoin(path, "/download"),
method: "GET",
queryParams: _queryParams
});
const a = document.createElement("a");
a.href = fetchPath;
a.download = label;
a.style.display = "none";
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
};
exports.downloadItems = downloadItems;