export function buildURL(query, limit = 20, offset = 0) { let url = "https://data.enseignementsup-recherche.gouv.fr/api/explore/v2.1/catalog/datasets/fr-esr-parcoursup/records?" url += "limit=" + limit url += "&offset=" + offset if (query && query.trim() !== "") { url += "&where=search(lib_for_voe_ins, '" + query + "')" } return url } export async function fetchFormations(query, limit = 20, offset = 0) { const url = buildURL(query, limit, offset) const response = await fetch(url) if (!response.ok) { throw new Error("Erreur HTTP") } return await response.json() }