Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird POST behaviour after upgrading to 2.50.0 (from 2.49.0) #1309

Closed
mpangrazzi opened this issue Dec 9, 2014 · 5 comments · Fixed by #1310
Closed

Weird POST behaviour after upgrading to 2.50.0 (from 2.49.0) #1309

mpangrazzi opened this issue Dec 9, 2014 · 5 comments · Fixed by #1310

Comments

@mpangrazzi
Copy link

Hi!

I've upgraded request to 2.50.0 and I've noticed a very weird behaviour when doing a request.post (application/x-www-urlencoded).

// client

var request = require('request');

request.post('http://localhost:3000/login', {
  form: { username: 'test', password: 'test' },
  json: true
}, function(err, res, body) {
  console.log(res.body);
});
// server

var express = require('express');
var router = express.Router();

// ...

router.post('/login', function(req, res) {
  console.log(req.body);
  res.json({ status: 'ok' });
});

With request 2.49.0, the req.body on server is the expected:

{ username: 'test', password: 'test' }

With request 2.50.0, the req.body on server is the following:

{ '"username': 'test', password: 'test"' } // ???

I'm using body-parser on Express apps and koa-body on Koa apps.

(obviously, this behaviuor broke all my tests and I have to switch back to 2.49.0)

@nylen
Copy link
Member

nylen commented Dec 9, 2014

Don't use form to do JSON POST requests; use body instead.

@nylen nylen closed this as completed Dec 9, 2014
@simov
Copy link
Member

simov commented Dec 9, 2014

@nylen this is a huge bug, it broke my whole module as well, pushing a temporary fix.

@onemenny
Copy link

this is realy annoying
please fix

@simov
Copy link
Member

simov commented Dec 10, 2014

Fixed in #1310

@nylen
Copy link
Member

nylen commented Dec 10, 2014

Fixed in version 2.51.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants