Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get url params value in node js

// get url params values with node js
const url = require('url');
const http = require('http');
http.createServer(function(req, res) {
    res.writeHead(200, {'Content-Type': 'text/html'});
    var q = url.parse(req.url, true).query;
    for(let v in q) {
        /**
         * Properties values will be inside: q[v] and property will be: v
         */
        res.write("<h2>"+q[v]+"</h2>")
        console.log(q[v]);
    }
    res.end()
}).listen(3030) // 127.0.0.1:3030
 
PREVIOUS NEXT
Tagged: #url #params #node #js
ADD COMMENT
Topic
Name
4+2 =