Code cleanup

This commit is contained in:
Sam
2023-12-18 14:40:30 +01:00
parent 76cf6eb069
commit 7b1f567111

View File

@@ -1,24 +1,9 @@
const request = ( url, params = {}, method = 'GET' ) => {
let options = {
method
};
if ( 'GET' === method ) {
url += '?' + ( new URLSearchParams( params ) ).toString();
} else {
options.body = JSON.stringify( params );
}
return fetch( url, options ).then( response => response.json() );
const request = ( url, params = {}) => {
url += '?' + ( new URLSearchParams( params ) ).toString();
fetch( url );
};
const get = ( url, params ) => request( url, params);
const get = ( url, params ) => request( url, params, 'GET' );
// SQL test
function sendata(naam, score) {
get('https://oege.ie.hva.nl/~hossan/GetData.php', { name: naam, score: score } )
.then( response => {
// Do something with response.
} );
get('https://oege.ie.hva.nl/~hossan/GetData.php', { name: naam, score: score } );
}