import axios, { AxiosError } from "axios"; import type { ConvertSchema } from "Types/ApiCalls/ConvertBackendCallsTypes"; export async function ConvertMoleculeToStandart( data: ConvertSchema, ): Promise { try { const response = await axios.post( import.meta.env.VITE_MOLECULAR_BACKEND_URL + "/convert", { text: data.inputText, format: data.inputFormat, convert_3d: data.make_3d, add_hydrogen: data.add_h, optimize_geometry: data.optimize, }, ); // Response from the FastAPI JSONResponse return response.data.molfile; } catch (error) { //Error handling if (axios.isAxiosError(error)) { // Do something with the axios error... return error; } else { throw error; } } } export async function GetInFormats(): Promise< { [key: string]: string } | AxiosError > { try { const response = await axios.get( import.meta.env.VITE_MOLECULAR_BACKEND_URL + "/informats", ); return response.data; } catch (error) { //Error handling if (axios.isAxiosError(error)) { // Do something with the axios error... return error; } else { throw error; } } }