UNPKG

leumas-private-shared

Version:

Private React JSX Package For Leumas Shared Components, Headers, Footers, Asides, Login Pages, API Key Manager and much more. Styles and everything reusable to avoid DRY code across all of our subdomains

20 lines (19 loc) 830 B
// fetchSchemas.js /** * Fetches available schema names from the server. * @param {function} onSuccess - Callback function to handle success. * @param {function} onError - Callback function to handle error. * @param {string} apiEndpoint - API endpoint to fetch schemas. * @param {array} excludedSchemas - List of schemas to be excluded. */ export const fetchSchemas = (onSuccess, onError, apiEndpoint, excludedSchemas) => { fetch(`${apiEndpoint}/schema`) .then(res => res.json()) .then(data => { const filteredSchemas = data .filter(schema => !excludedSchemas.includes(schema)) .sort((a, b) => a.localeCompare(b)); // Sort schemas alphabetically onSuccess(filteredSchemas); }) .catch(error => onError(error)); };