I have a database that stores all the users who have logged into my website and want them to be able to delete their account. So I made a function that works and removes the user's accs, but the only problem I'm having is that I can't seem to connect the js file that has the button event listener to my nodejs file with the function.
// node.js file let id = 1; /* delete user from mysql db */ async function delUsers() { /* actually hardcoded id, need to implement users id when a user can login into the site */ await pool.query('DELETE FROM user WHERE id = ?', [id]); console.log("Deleting.."); };
// js file 'use strict'; console.log('linked'); let del = document.getElementById('delbutton').addEventListener('click', Del); let a = require('./delete.js'); function Del() { let b = a.DelUser(); }
I tried using module.exports with module.import, require, sessionstorage, localstorage. I want my button to work and delete my 1 user
nodejs is used for backend.
Global objects "window, document..." are only included in the browser.