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 8798995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:13:07+00:00 2026-06-14T00:13:07+00:00

How can I merge these two get requests into one? app.get(‘/:something/:else’, function(req, res){ res.render(something);

  • 0

How can I merge these two get requests into one?

app.get('/:something/:else', function(req, res){
  res.render("something");
});

app.get('/:something', function(req, res){
  res.render("something");
});

I tried this and it didn’t work.

app.get('(/:something|/:something/:else)', function(req, res){
  res.render("something");
});
  • 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-14T00:13:08+00:00Added an answer on June 14, 2026 at 12:13 am

    I am not 100% sure but I think you can do:

    '/:something/:else?'
    

    Otherwise you can either store the middleware function in a variable:

    var m = function (req, res) { }
    app.get('/one', m);
    app.get('/two', m);
    

    Or you can use a regular expression.

    app.get(/^\/commits\/(\w+)(?:\.\.(\w+))?$/, function(req, res){
      var from = req.params[0];
      var to = req.params[1] || 'HEAD';
      res.send('commit range ' + from + '..' + to);
    });
    

    There is some info on the Express.js site: http://expressjs.com/api.html#app.VERB

    The author also has a client-side library that is based on Express.js routing so maybe you can find more info there. That’s where I could the ‘?’ example. The library is called page.js and can be found: http://visionmedia.github.com/page.js/

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

Sidebar

Related Questions

How can you get the number of affected rows from executing a MERGE INTO...
I have this simple example I can't seems to get working : MERGE INTO
I need to combine/merge two php functions, but I can't get the syntax right.
How can I merge these two hashes: {:car => {:color => red}} {:car =>
I have two functions that i'm hoping i can put into one and can
EntityManager.merge() can insert new objects and update existing ones. Why would one want to
var _sel1 = $('.red'); var _sel2 = $('.yellow'); How can I merge them into
I want to know if these two queries can be merged, I will explain
I need to combine rows from two Excel worksheets into one long row, based
I need to write a java application which can merge docx files. Any suggestions?

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.