1 question: If the application crashes, does it crash only for the user (who has the error) or for all?

2 question: The site has a form, the Ajax sends a post request to the server, where it is processed. However, the form can be sent empty (if desired) and then the application crashes. To avoid this, you need to check the variable to 'undefined' and return an error. However, it turned out that I, for some reason, cannot with the help of res.end () complete the execution of the code, the error still crashes, as if the variables are initialized before any actions.

app.post('/record', function(req, res, next) { res.send('error'); res.end(); //Всё равно вылетает ошибка из кода ниже, так как res.body.id из пост запроса == Indifined pool.query("INSERT INTO `record` (id) VALUES ("+pool.escape(req.body.id), function(err, rows, fields) { if (err) {console.log(err); res.send('error');} ratePlease(0, 0); }); }) 

 ER_TRUNCATED_WRONG_VALUE_FOR_FIELD: Incorrect integer value: 'undefined' for column 'novel_id' at row 1 

    1 answer 1

    1. For all.

    2. res.send ('error'); res.end (); replace with return res.send ('error');