Files
J1B2-Game-controller/web/js/Database.js
2024-01-17 16:37:05 +01:00

23 lines
709 B
JavaScript

function sendData(naam, score) {
const request = ( url, params = {}) => {
url += '?' + ( new URLSearchParams( params ) ).toString();
fetch( url );
};
const get = ( url, params ) => request( url, params);
get('https://oege.ie.hva.nl/~hossan/postData.php', { name: naam, score: score } );
}
function getData(name){
// Fetch data from the database, put it in an array, and log it to the console
//met backticks als " " kan je variabelen in een string zetten
return fetch (`https://oege.ie.hva.nl/~hossan/getData.php?name=${name}`) // Add return here
.then(response => response.json())
.then(data => {
requesteddata = data;
console.log(data);
});
}