Skip to content

Instantly share code, notes, and snippets.

@YonatanKra

YonatanKra/flyWeight.js

Last active Feb 7, 2020
Embed
What would you like to do?
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