Closed
Description
- Version: v8.10.0
- Platform: Linux 4.15.0-29-generic Ubuntu SMP Tue Jul 17 15:39:52 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
- Subsystem: http
When passing an URL
with query params as the first argument to http.get()
method, the query is ignored.
const URL = require('url');
const http = require('http');
const assert = require('assert');
function parseJsonResp(next) {
return function(resp) {
var raw = '';
resp.on('data', function(chunk) {
raw += chunk;
});
resp.on('end', function() {
next(null, JSON.parse(raw));
});
}
};
const url = URL.parse('http://httpbin.org/get');
url.query = {foo: 'bar'}
http.get(url, parseJsonResp(function(err, obj) {
assert(obj.args.foo === 'bar'); // It fails here
}));