ejs templating
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
var app = {};
|
||||
|
||||
/*
|
||||
|
||||
app.api = (function(app){
|
||||
var baseURL = '/api/v0/'
|
||||
|
||||
@ -85,7 +85,6 @@ app.api = (function(app){
|
||||
|
||||
return {post: post, get: get, put: put, delete: remove}
|
||||
})(app)
|
||||
*/
|
||||
|
||||
app.auth = (function(app) {
|
||||
var user = {}
|
44
consumerWebsite/public/js/contact.js
Normal file
44
consumerWebsite/public/js/contact.js
Normal file
@ -0,0 +1,44 @@
|
||||
require('dotenv').config({ path: path.resolve(__dirname, '../../../.env') })
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const form = document.getElementById('form');
|
||||
|
||||
// Set the new value for the access_key input field
|
||||
form.querySelector('input[name="access_key"]').value = process.env.emailKey;
|
||||
|
||||
form.addEventListener('submit', async (event) => {
|
||||
event.preventDefault(); // Prevent default form submission
|
||||
|
||||
// Create a FormData object to include the key
|
||||
const formData = new FormData(form);
|
||||
|
||||
// Submit the form using fetch API
|
||||
try {
|
||||
const response = await fetch('https://api.web3forms.com/submit', {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
// Handle the API response
|
||||
//console.log(result);
|
||||
|
||||
if (result.success) {
|
||||
// Form submitted successfully, display notification
|
||||
alert('Form submitted successfully!');
|
||||
location.reload()
|
||||
// You can replace the alert with your custom notification logic
|
||||
} else {
|
||||
// Form submission failed, display error notification
|
||||
alert('Form submission failed. Please try again.');
|
||||
// You can replace the alert with your custom error notification logic
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
//console.error('Error:', error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user