Files
public-html2/parcoursup/api.js
T

24 lines
608 B
JavaScript
Raw Normal View History

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 + "')"
2026-03-17 17:34:34 +01:00
}
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()
}