2023-03-25 16:31:36 +01:00
<search>
<label>
2023-03-26 15:03:06 +02:00
<input oninput={searchF} type="input" placeholder= {state.formation}>
2023-03-25 16:31:36 +01:00
<div id="list-formations">
2023-03-26 15:03:06 +02:00
<ul>
<li each={item in this.state.items}>
<a href={item.path} target="_blank">{item.name}</a>
<span>{item.count}</span>
</li>
</ul>
2023-03-25 16:31:36 +01:00
</div>
</label>
<script>
2023-03-26 15:03:06 +02:00
async function formation(){
let result = await fetch("https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&q=&sort=tri&facet=fili&timezone=Europe%2FBerlin")
let resultats = await result.json()
let table = resultats["facet_groups"][0]["facets"]
return table
}
2023-03-25 16:31:36 +01:00
export default function search(){
2023-03-26 15:03:06 +02:00
return {
onBeforeMount(props, state) {
// initial state
this.state = {
formation: props.formation,
items: null
}
formation().then((response) => {
this.update({
items: response
})
})
console.log(this.state.items)
},
searchF(){
formation().then((response) => {
this.update({
items: response
})
})
console.log(this.state.items)
2023-03-25 16:31:36 +01:00
}
}
}
2023-03-26 15:03:06 +02:00
2023-03-25 16:31:36 +01:00
</script>
</search>