request / request-promise

The simplified HTTP request client 'request' with Promise support. Powered by Bluebird.
ISC License
4.76k stars 297 forks source link

querystring doesn't pass collections properly #305

Closed rajasharan closed 5 years ago

rajasharan commented 5 years ago

When I use below code to fire request:

var rp = require('request-promise');

var options = {
    uri: 'http://localhost:8090',
    qs: {
        type: ['abc', 'xyz']
    }
};

rp(options).catch(err => console.log(err));

In the server logs I can see:

... /?type%5B0%5D=abc&type%5B1%5D=xyz ...

Which I guess decodes to:

/?type[0]=abc&type[1]=xyz

But node builtin querystring doesn't parse like that: https://nodejs.org/api/querystring.html#querystring_querystring_parse_str_sep_eq_options

I was expecting this library to produce:

/?type=abc&type=xyz
rajasharan commented 5 years ago

nevermind - had to use useQuerystring: true in the options. https://www.npmjs.com/package/request#requestoptions-callback