const http=require('http') const querystring=require('querystring') const server = http.createServer((req,res) =>{ console.log('method:', req.method)//GET const url = req.url console.log('url:',url) req.query=querystring.parse(url.split('?')[1]) console.log('query:',req.query) res.end( JSON.stringify(req.query) ) }) server.listen(7000) console.log('ok')
http
querystring
Extracted from the query string parameter may use require('querystring').parse
a function, or may be true
passed as a second argument require('url').parse
: