Skip to content

Instantly share code, notes, and snippets.

@YonatanKra
Last active February 7, 2020 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YonatanKra/4c27d8b8922d2ad49adde18ff63192dd to your computer and use it in GitHub Desktop.
Save YonatanKra/4c27d8b8922d2ad49adde18ff63192dd to your computer and use it in GitHub Desktop.
FlyWeight client
(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);
})();
<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