P
P
pshy_soch2020-04-20 16:18:59
Node.js
pshy_soch, 2020-04-20 16:18:59

Node.JS body-parser error, what should I do?

Hello Habr!
Why does such a fak-up appear when working with body-parser

const express = require('express');
const app = express();
var bodyParser = require('body-parser')

 let urlcodedParser = app.use(bodyParser.urlencoded({ extended : false}));

app.get('/', (req,res) =>{
    res.sendFile(__dirname + '/index.html');

})
app.post('/index', urlcodedParser, (req,res)=>{
    console.log(req.body);
})


app.listen(3000,  (req,res) =>{
    console.log('ON')
})

Cannot POST / appears.
What to do?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question