I am new to JavaScript recently moved from python.
I am coding fine with my coffee , but this code throws an error, saying that : 'function' is declared but its value is never read. What's wrong with my code. I had also inscribed this script in my index.html and in this tag.
=> <button type="submit" id="login" onclick="sendCred()">
import net from 'net';
var socket = new net.Socket();
function sendCred(){
// sending the credentials to the python server on ("localhost", 8000)
var net = require('net');
var host = 'localhost'
var port = 8000
var username = this.username.value;
var password = this.password.value;
var socket = new net.Socket();
socket.connect(port, host, ()=> {
socket.write(username + "." + password);
});
socket.on('data', (data) => {
console.log(`${data}`);
socket.destroy();
});
// authenticating the process;
if (user === "Gautam"){
if (passw === "Admin"){
document.write("Auth SuccessFul")
}else{
var textField = document.querySelector("#error");
var error = "you've entered a wrong password, click "
redrctHtml = error + "\n<a href=\"#\">here</a>" + " to change password";
textField.innerHTML = redrctHtml;
}
}
};```