Files
parcer/src/api/integration.ts

17 lines
692 B
TypeScript
Raw Normal View History

2024-09-17 22:36:40 +05:30
import { default as axios } from "axios";
2024-11-01 08:25:14 +05:30
import { apiUrl } from "../apiConfig";
2024-09-17 22:36:40 +05:30
2024-09-20 17:07:41 +05:30
export const handleUploadCredentials = async (fileName: string, credentials: any, spreadsheetId: string, range: string): Promise<boolean> => {
2024-09-17 22:36:40 +05:30
try {
2024-11-01 08:25:14 +05:30
const response = await axios.post(`${apiUrl}/integration/upload-credentials`, { fileName, credentials: JSON.parse(credentials), spreadsheetId, range });
2024-09-18 22:31:48 +05:30
if (response.status === 200) {
return response.data;
2024-09-19 09:14:31 +05:30
} else {
2024-09-18 22:31:48 +05:30
throw new Error(`Couldn't make gsheet integration for ${fileName}`);
}
2024-09-17 22:36:40 +05:30
} catch (error) {
2024-09-17 22:36:54 +05:30
console.error('Error uploading credentials:', error);
2024-09-18 22:31:48 +05:30
return false;
2024-09-17 22:36:40 +05:30
}
2024-09-20 17:07:41 +05:30
};