24 lines
586 B
JavaScript
24 lines
586 B
JavaScript
|
|
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 get = ( url, params ) => request( url, params, 'GET' );
|
|
|
|
|
|
// SQL test
|
|
function sendata(naam, score) {
|
|
get( 'http://oege.ie.hva.nl/~hossan/GetData.php', { naam: naam, score: score } )
|
|
.then( response => {
|
|
// Do something with response.
|
|
} );
|
|
} |