Files
public-html2/parcoursup/api.js
T

21 lines
497 B
JavaScript
Raw Normal View History

2026-03-31 17:54:23 +02:00
export function buildURL(query) {
let url =
"https://data.enseignementsup-recherche.gouv.fr/api/explore/v2.1/catalog/datasets/fr-esr-parcoursup/records?limit=10"
if (query && query.trim() !== "") {
url += "&where=search(lib_for_voe_ins, '" + query + "')"
}
return url
2026-03-30 15:05:11 +02:00
}
2026-03-31 17:54:23 +02:00
export async function fetchFormations(query) {
const url = buildURL(query)
const response = await fetch(url)
2026-03-31 17:54:23 +02:00
if (!response.ok) {
throw new Error("Erreur HTTP")
2026-03-20 01:51:08 +01:00
}
2026-03-31 17:54:23 +02:00
return await response.json()
2026-03-30 15:05:11 +02:00
}