diff --git a/web/game.js b/web/game.js index f4c0b35..9a5f78a 100644 --- a/web/game.js +++ b/web/game.js @@ -710,23 +710,3 @@ function game() { } } - -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(){ - // Fetch data from the database, put it in an array, and log it to the console - return fetch ('https://oege.ie.hva.nl/~hossan/getData.php') // Add return here - .then(response => response.json()) - .then(data => { - requesteddata = data; - }); -} diff --git a/web/index.html b/web/index.html index 59ae5bd..3934d4d 100644 --- a/web/index.html +++ b/web/index.html @@ -9,6 +9,7 @@ + diff --git a/web/js/Database.js b/web/js/Database.js new file mode 100644 index 0000000..c46eb7c --- /dev/null +++ b/web/js/Database.js @@ -0,0 +1,20 @@ + +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(){ + // Fetch data from the database, put it in an array, and log it to the console + return fetch ('https://oege.ie.hva.nl/~hossan/getData.php') // Add return here + .then(response => response.json()) + .then(data => { + requesteddata = data; + }); +}