Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
Dynamically adding a route with Express using frontend parameter

I'm trying to build an application will allow me to take a String parameter from the frontend, and create an Express route from that. Is that possible?

var express = require('express');
var router = express.Router();

router.post('/newAPI/:name', function(req, res, next) {
    var name = req.params.name;
    router.get('/'+name, function(req, res, next) {
        res.send({"name":""+name});
    });
});

With this, would calling localhost:3000/newApi/bob create a new route localhost:3000/bob that returns {"name":"bob"}?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It will work, unless you restart the application.

Also, just use {"name": name}.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!