SAE_RIOT_2024/model.js

19 lines
678 B
JavaScript
Raw Normal View History

2024-06-21 19:31:52 +02:00
function execQuery(table, filter = "all", id = -1){
let baseHttpRequest = "https://dwarves.iut-fbleau.fr/~fauvet/api/"
let computeHttpRequest;
if(filter !== undefined){
switch(table){
case "songs":
computeHttpRequest = baseHttpRequest+table+"?title="+filter;
default :
computeHttpRequest = baseHttpRequest+table+"?name="+filter;
}
} else if(id !== undefined) {
computeHttpRequest = baseHttpRequest+table+"/"+id;
} else {
computeHttpRequest = baseHttpRequest+table;
}
return fetch(computeHttpRequest).then(response => {
return response.json();
});
};