req.query for method POST

135 views
Skip to first unread message

Prashanth

unread,
Jan 28, 2012, 9:42:49 AM1/28/12
to expre...@googlegroups.com
Hi,

What is the intension behind not adding req.query for in the case
of method is post? I get it that if i use bodyparser its part of the
req.body but what makes it different from get.


--
regards,
Prashanth
twitter: munichlinux
irc: munichlinux, JSLint, munichpython.

vision media [ Tj Holowaychuk ]

unread,
Jan 28, 2012, 11:55:02 AM1/28/12
to expre...@googlegroups.com
it should work for any method, this is the query() middleware (used by express internally):

module.exports = function query(){
  return function query(req, res, next){
    req.query = ~req.url.indexOf('?')
      ? qs.parse(parse(req.url).query)
      : {};
    next();
  };
};

so if there's a query-string you should have it

--
You received this message because you are subscribed to the Google Groups "Express" group.
To post to this group, send email to expre...@googlegroups.com.
To unsubscribe from this group, send email to express-js+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/express-js?hl=en.




--
Tj Holowaychuk
Vision Media
President & Creative Lead

Prashanth

unread,
Jan 28, 2012, 2:53:04 PM1/28/12
to expre...@googlegroups.com
Hi,

On Sat, Jan 28, 2012 at 10:25 PM, vision media [ Tj Holowaychuk ]
<t...@vision-media.ca> wrote:
> it should work for any method, this is the query() middleware (used by
> express internally):

It dint.

>
> module.exports = function query(){
>   return function query(req, res, next){
>     req.query = ~req.url.indexOf('?')
>       ? qs.parse(parse(req.url).query)
>       : {};
>     next();
>   };
> };
>
> so if there's a query-string you should have it

I dont think post parameters are part of query string.

Paul Vencill

unread,
Jan 28, 2012, 3:03:51 PM1/28/12
to expre...@googlegroups.com

Post parameters will only be on the query string if your form method is get. Otherwise it's in the body

vision media [ Tj Holowaychuk ]

unread,
Jan 28, 2012, 3:06:52 PM1/28/12
to expre...@googlegroups.com
yeah the request body == req.body, query-string == req.query
Reply all
Reply to author
Forward
0 new messages