{"size": 1131, "ext": "js", "max_stars_repo_path": "public/js/forgotpwd.js", "max_stars_repo_name": "siddique-shahida/Robotics_Hut", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/js/forgotpwd.js", "max_issues_repo_name": "siddique-shahida/Robotics_Hut", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/js/forgotpwd.js", "max_forks_repo_name": "siddique-shahida/Robotics_Hut", "max_forks_repo_forks_event_min_datetime": "2022-01-25T09:47:13.000Z", "max_forks_repo_forks_event_max_datetime": "2022-01-25T09:47:13.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 34.2727272727, "max_line_length": 84, "alphanum_fraction": 0.6648983201}
const sendButton = document.querySelector('button');
const forgotMessage = document.querySelector('#sentpwdmsg');

function sendPassword(event) {
    event.preventDefault();
    const fromEmail = document.querySelector('#email').value;
    const subject = "The Robotics Hut - Check your password";

    //This is will be sent in the backend...
    let text = "Hello there! This is your forgotten password...";

    const data = { fromEmail, subject, text };
    console.log(data);

    fetch('http://localhost:8080/forgot', {
        method: 'POST',
        body: JSON.stringify(data),
        headers: { 'Content-Type': 'application/json' }
    }).then(console.log('Server recieved our data'))
        .then(res => res.json());

    //Displays confirmation message of the email sent with the password...
    displayMessage(event);
}


function displayMessage(event) {
    event.preventDefault();
    console.log("Password has been sent successfully!");
    forgotMessage.innerHTML = "<small>Password has been sent successfully!<small>";
}

sendButton.addEventListener("click", sendPassword, false);