nodejs get route path url code example

Example 1: route parameter in node

var express = require('express');
var fs  = require('fs');
var app= express();
 app.get('/index/profile/:id',function(req,res){
    //  res.send('profile with id' + req.params.id)

    
    
 });
app.listen(3000,'127.0.0.1');
console.log('lsitng');

Example 2: get value from path variable node js

exports.doIt = function(req, res, next) {
    var group = new Group(req.body);

    console.log(req.params);

    group.userId = req.params.userId;

    group.save(new dataCallbacks(req, res, next, "Group").insert());
});

Tags:

Html Example