mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-07 22:31:18 -06:00
* add Excel download option * add back attribute export * add types and check for download filetype * add xlsx package * move csv and excel conversion to internal endpoints --------- Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
19 lines
481 B
TypeScript
Executable File
19 lines
481 B
TypeScript
Executable File
export const fetchFile = async (
|
|
data: { json: any; fields?: string[]; fileName?: string },
|
|
filetype: string
|
|
) => {
|
|
const endpoint = filetype === "csv" ? "csv-conversion" : "excel-conversion";
|
|
|
|
const response = await fetch(`/api/internal/${endpoint}`, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
body: JSON.stringify(data),
|
|
});
|
|
|
|
if (!response.ok) throw new Error("Failed to convert to file");
|
|
|
|
return response.json();
|
|
};
|