D
D
Dvorak2016-09-18 00:31:33
Node.js
Dvorak, 2016-09-18 00:31:33

Why can't I get data from the form?

There is this form:

<form method='post' action='/path'>
      <input type='text' name='login' placeholder='Введите ник'><br>
      <input type='password' name='pass' placeholder='Введите пароль'><br>
      <input type='button' name='button' value='ОК' id='button'>
    </form>

I receive data like this:
const express = require('express'),
         bodyParser = require('body-parser'),
         app = express();
app.use(bodyParser.urlencoded({extended: true}));
app.post('/path', (req, res) => {
  console.log('Request')
  console.log(req.body);
});

but nothing is output in the console. Where is the mistake?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Amazing-Space-Invader, 2016-09-18
@allishappy

Hey! Your button does nothing. Change

<input type='button' name='button' value='ОК' id='button'>
on the
<input type='submit' name='button' value='ОК' id='button'>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question