Last active
February 7, 2020 06:47
-
-
Save YonatanKra/4c27d8b8922d2ad49adde18ff63192dd to your computer and use it in GitHub Desktop.
FlyWeight client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
function json(response) { | |
return response.json() | |
} | |
function getData(url) { | |
fetch(url, { | |
method: 'post', | |
headers: { | |
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8" | |
} | |
}) | |
.then(json) | |
.then(function (data) { | |
myUsers = data; | |
console.log('Finished fetching data'); | |
}) | |
} | |
function regularData() { | |
getData('/getData') | |
} | |
function flyWeightData() { | |
getData('/getFlyWeightData'); | |
} | |
let myUsers; | |
document.getElementById('request').addEventListener('click', regularData); | |
document.getElementById('requestFlyWieght').addEventListener('click', flyWeightData); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button id="request">Request data</button> | |
<button id="requestFlyWieght">Request light weight data</button> | |
<script src="flyWeight.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment