Home > front end >  After using the body - the parser still cannot handle a post request
After using the body - the parser still cannot handle a post request

Time:09-25

Entrance js:
 
Var express=the require (' express ');
Var bodyParser=the require (' body parser - ');
Var router=the require ("./router. Js');
Var app=express ();

App. Use ('/node_modules, express the static ('./node_modules'));
App. Use ('/public, express the static ('./public '));
App engine (' HTML ', the require (' express - art - the template '));
App. Use (bodyParser. Urlencoded ({extended: false}));
App. Use (bodyParser. Json ());

App. Use (router);

App. Listen (909, function () {
The console. The log (' running server at port 909 ');
});

Web form elements are as follows:
 














Simple console output in the router:
 router. Post ('/students/new ', function (the req, res) {
The console. The log (the req. Body);
});

But no reaction after the operation console, the page also shows always post,
solve!!!!!! How to get to the post data??

CodePudding user response:

Himself too not careful, & lt; The form action="/student/new method=" post "& gt; Should be students, don't jump in the past
  • Related