# неопределенная ошибка: при передаче объекта в шаблон e js через nodejs - PullRequest
0 голосов
/ 19 июня 2020

Я использую двигатель e js вместо pug. В моем реестре есть ошибки, которые не определены. Было очень мало шансов, что я смогу получить сообщения проверки. Как решить?




    app.post('/', urlencodedParser, [
        check('username', 'username should be email id').isEmail(),
        check('password', 'Password must be in 5 character').isLength({ min: 5 })
    ], (req, res) => {
        const errors = validationResult(req);

        //console.log(typeof(JSON.stringify(errors.mapped())));

        res.render('index', { login:"Login Detail", error:errors.mapped()});

    });


    <!Doctype html>
    <html>
        <head>
            <title>Database</title>
        </head>
        <body>
            <h1> <%= login %></h1>
            <form method="POST" action="/">
                <input type="text" name="username">
                <% if (error) { %>
                    <h2><%= error.username %></h2>
                  <% } %>
                <input type="text" name="password">
                <input type="submit" name="submit" value="Submit">
            </form>
        </body>`enter code here`
    </html>


...