Skip to content

Instantly share code, notes, and snippets.

@aerrity
aerrity / client.js
Last active August 30, 2024 15:49
Node, Express & MongoDB: Button click example
console.log('Client-side code running');
const button = document.getElementById('myButton');
button.addEventListener('click', function(e) {
console.log('button was clicked');
fetch('/clicked', {method: 'POST'})
.then(function(response) {
if(response.ok) {
console.log('click was recorded');