Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8228685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:32:35+00:00 2026-06-07T16:32:35+00:00

I’ve read several other questions about how to configure express to listen on POST

  • 0

I’ve read several other questions about how to configure express to listen on POST requests but I continually get empty JSON or undefined when I try to print out simple POST queries that I send to the server.

I have this set up:

//routes
require('./routes/signup.js')(app);

// Configuration
app.configure(function(){
    app.use(connect.bodyParser());
    app.use(express.methodOverride());
    app.register(".html", hulk);
    app.set('views', __dirname + '/views');
    app.set('view options', {layout: false});
    app.set('view engine', 'hulk');
    app.use(express.static(__dirname + '/public'));
    app.use(app.router);
});

then routes/signup.js looks like this:

var common_functions = require('../common_functions.js');
var views            = require('../views/view_functions.js');
var globals          = require('../globals.js');
var mongoose         = require('mongoose');

//declare classes
var User = mongoose.model('User');

module.exports = function(app){
    /**
     * SignUp GET
     */
    app.get('/signup', function(req, res){
        res.render('signup/signup.html');
    });

   /**
    * SignUp POST
    */
   app.post('/signup', function(req, res){
    console.log(JSON.stringify(req.body));
    console.log(req.body);
    res.send(JSON.stringify(req.body));
});

}

the template looks like this:

{{> header.html }}
{{> navigation.html }}
{{> body.html }}
<form action="/signup" method="post">
    <input name="email"/>
    <input type="submit"/>
</form>
{{> footer.html }}

There is nothing of particular interest in any of the partials.

The two console.log‘s print out undefined while the res.send() simply return the same html as before. What am I doing wrong here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:32:37+00:00Added an answer on June 7, 2026 at 4:32 pm

    Express auto-mounts the router middleware, if not already mounted, on the first call to any of the router’s verb functions. So, by loading in routes above the config block, the router middleware is the first middleware in the stack (above the bodyParser). Moving the route file loading below the configure block will fix this issue.

    From the configuration section of the Express.js docs:

    Note the use of app.router, which can (optionally) be used to mount the application routes, otherwise the first call to app.get(), app.post(), etc will mount the routes.

    http://expressjs.com/guide.html#configuration

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.