Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save manekinekko/445d08d7cfd58e8c24c97ce0f3d49b2d to your computer and use it in GitHub Desktop.
Save manekinekko/445d08d7cfd58e8c24c97ce0f3d49b2d to your computer and use it in GitHub Desktop.
<div id="content"></div>
<button id="load">Vador says...</button>
<script>
const content = document.querySelector('#content');
const click = function() {
content.innerHTML = 'Luke, ...';
fetch('/api/users/luke')
.then(response => response.json())
.then(data => {
content.innerHTML = data.response;
});
};
document.querySelector('#load').addEventListener('click', click);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment