`hasOwnProperty` no longer on parsed object #61

nicolaasmatthijs opened this Issue Apr 30, 2013 · 3 comments


None yet

4 participants


I'm using node-querystring as part of Express.js. After updating to the latest version of Express, the request body object passed into POST requests no longer has the hasOwnProperty function. I think I've been able to narrow this down to the changes made in #58 .

serv.post('/api/test', function(req, res) {
    if (req.body.hasOwnProperty('test') {
        --> Error: req.body has no method hasOwnProperty. The body is {'test': 'test'}

Was this a deliberate change? If so, can you explain the rationale behind it? Thanks!


It's was done to prevent the request body from messing with global Object.prototype. Have a look at https://github.com/visionmedia/node-querystring/blob/master/test/parse.js#L154
Node is such a nightmare sometimes. haha

tj commented May 2, 2013

yeah I thought this may break some people's tests as well if they're using Object#should with should.js, but overall it's a necessary change

@tj tj closed this May 2, 2013
@kfinn kfinn referenced this issue in amachang/facebook-node-sdk May 2, 2013

Removed reference to this.request.query.hasOwnProperty #7

@tj tj added a commit that referenced this issue May 3, 2013
@tj add proto restoration. Closes #61 3d4e0e0
@jasonfarrell jasonfarrell added a commit to UseAllFive/node-querystring that referenced this issue Oct 23, 2013
@tj add proto restoration. Closes #61 f362d5c

where is the solution for this?

@duknic duknic added a commit to UniversityofWarwick/express-form that referenced this issue Jul 28, 2016
@duknic duknic Fix bug where parsed req objects no longer have 'hasOwnProperty', as … 4fd9952
@imbolc imbolc added a commit to imbolc/express-pouchdb that referenced this issue Jul 29, 2016
@imbolc imbolc Fix "req.query.hasOwnProperty is not a function" error
`req.query` does not have hasOwnProperty method for a long time: tj/node-querystring#61
@imbolc imbolc referenced this issue in pouchdb/express-pouchdb Jul 29, 2016

Fix "req.query.hasOwnProperty is not a function" error #355

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment