UNPKG

leumas-universal-crud-react

Version:

Leumas Universal CRUD to a dynamic Endpoint, Setup your own Dynamic Endpoint and Use Leumas API to send to your MONGO clusters

20 lines (18 loc) 707 B
// sendBulkRequests.jsx import axios from 'axios'; /** * Sends bulk API requests. * @param {string} endpoint - The API endpoint for sending bulk requests. * @param {Array} bulkRequests - An array of requests to be sent in bulk. * @param {function} onSuccess - Callback function to handle success. * @param {function} onError - Callback function to handle error. */ export const sendBulkRequests = async (endpoint, bulkRequests, onSuccess, onError) => { try { const response = await axios.post(endpoint, bulkRequests); onSuccess(response.data); } catch (error) { console.error("Error sending bulk requests:", error); onError(error); } };