Parsing Query String in node.js

后端 未结 5 1213
生来不讨喜
生来不讨喜 2020-12-22 23:11

In this \"Hello World\" example:

// Load the http module to create an http server.
var http = require(\'http\');

// Configure our HTTP server to respond wit         


        
5条回答
  •  被撕碎了的回忆
    2020-12-23 00:01

    require('url').parse('/status?name=ryan', {parseQueryString: true}).query
    

    returns

    { name: 'ryan' }
    

    ref: https://nodejs.org/api/url.html#url_urlobject_query

提交回复
热议问题