From da90479b2b9ae34595b2a0a1dcfca0fd0c64efd8 Mon Sep 17 00:00:00 2001 From: Fauvet Matthis Date: Fri, 21 Jun 2024 18:37:33 +0200 Subject: [PATCH] try to update items list --- onzer.riot | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/onzer.riot b/onzer.riot index 30d0192..0ff3b36 100644 --- a/onzer.riot +++ b/onzer.riot @@ -35,7 +35,6 @@ }; this.paintButton(); this.album_style = "isActivate"; - this.update(); }, onMounted(){ this.update(); @@ -45,7 +44,6 @@ }, click(e) { e.preventDefault(); - this.paintButton(); switch(e.target.value){ case "Albums": @@ -63,19 +61,14 @@ this.song_style = "isActivate"; this.state.search = "songs"; } - this.fetchData(e) + this.fetchData() this.update(); }, - async fetchData(event){ - event.preventDefault(); + async fetchData(){ let data = await this.execQuery(); - console.log(this.state.search); - console.log(data.results); - this.state = { + this.update({ items: data.results - }; - console.log(this.state.items); - this.update(); + }); }, execQuery(){ return fetch("https://dwarves.iut-fbleau.fr/~fauvet/api/"+this.state.search).then(response => { @@ -87,7 +80,6 @@ this.artist_style = "isDeactivate"; this.song_style = "isDeactivate"; } - }