Tuesday 19 March 2019

Node server hangs up when calling a request multiple times.

So I am making a login form for my website and when calling the /submitlogin post request it hangs up after few times 5-6. It doesn't matter if I change the input or not. Strangely it hangs outside this function and not while executing it.Here is the functionBasically, it accepts a form with name:,pass: and ask the SQL server a user with those exists. Gotta fix this before moving forward. Using Formidable, Express, Object-Hash.app.post('/submitlogin', function (req, res) { var form = new formidable.IncomingForm(); form.parse(req, function (err, fields, files) { var passhash = hash(fields.pass); console.log(fields.name, passhash); var sql = "SELECT * FROM `database`.users WHERE name='" + fields.name + "' AND passwordHashed='" + passhash + "';" con.query(sql, function (err, result) { if (err) throw err; console.log(result); }); }); }); No other function has this problem so I assume it is exclusively from this one but after hanging it doesn't hit this function in a breakpoint, so I assume this function must be faulty but why can't figure that out.Here is all the code.https://pastebin.com/2fCdkkYNThanks for the help!

Submitted March 19, 2019 at 11:44AM by emelrad12

No comments:

Post a Comment