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) 696 B
// runBlocks.js import axios from 'axios'; /** * Runs bulk endpoint 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 runBlocks = async (endpoint, bulkRequests, onSuccess, onError) => { try { const response = await axios.post(endpoint, bulkRequests); onSuccess(response.data); } catch (error) { console.error("Error running bulk requests:", error); onError(error); } };