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"}
?
via QuantumRich
No comments:
Post a Comment