I am very new to Express and making SPA's. Im trying to link JavaScript file to my contact.html file in order to send an email to an email address when the contact form is submitted. For some reason I cant seem to find the right place to put the code and I keep getting an error.
this is what my server.js looks like.
const express = require('express');
const path = require('path');
const app = express();
app.use('/static', express.static(path.resolve(__dirname, 'frontend', 'static')));
app.get('/*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'frontend', 'index.html'));
});
app.listen(process.env.PORT || 8080, () => console.log('Server running...'));
it is extremely possible that I am missing something or not explaining this properly so my apologies in advance.
Im not sure if i need to write the code in a new javascript file or an existing one, or if what im trying to do is even possible. Any help is appreciated.