The node express's bodyParser can't get the parameter in the GET request

express, get, node.js, parameters

Solution

If you are issuing a GET request, the URL parameters are not part of the body, and thus will not be parsed by the bodyParser middleware.

To access the query parameters, just reference `req.query`

Problem

I ajax an GET request in client side: ``` $.ajax({ url: '/update', type: 'get', data: { "key": key, "value": value }, success: function (data, err) { } }) ``` then at the node side, I want get the parameter ``` var showParam = function (req, res) { if (req.body) { for (var key in req.body) { console.log(key + ": " + req.body[key]); } res.send({status:'ok',message:'data received'}); } else { console.log("nothing received"); res.send({status:'nok',message:'no Tweet received'}); } } app.get('/update', function(req, res){ showParam(req, res); }) ``` The shell show the body is empty and undefined. But when I change the `get` to `post` (both at the client side and server side), everything is ok, I can get the parameter correctly. What's problem with my code? Do I miss something?

Original source