mirror of
https://github.com/formbricks/formbricks.git
synced 2025-12-30 02:10:12 -06:00
Co-authored-by: Johannes <johannes@formbricks.com> Co-authored-by: Piyush Gupta <piyushguptaa2z123@gmail.com> Co-authored-by: pandeymangg <anshuman.pandey9999@gmail.com>
19 lines
472 B
TypeScript
Executable File
19 lines
472 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/${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();
|
|
};
|