// runEndpoint.jsx
import axios from 'axios';

/**
 * Runs a single endpoint request.
 * @param {string} endpoint - The API endpoint for sending the request.
 * @param {object} requestData - The request data.
 * @param {function} onSuccess - Callback function to handle success.
 * @param {function} onError - Callback function to handle error.
 */
export const runEndpoint = async (endpoint, requestData, onSuccess, onError) => {
    try {
        const response = await axios.post(endpoint, [requestData]); // Wrapping the single endpoint in an array
        onSuccess(response.data);
    } catch (error) {
        console.error("Error running the endpoint:", error);
        onError(error);
    }
};
