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