Skip to content

Problem with query params #1300

@csbenjamin

Description

@csbenjamin

Reproduction

Steps to reproduce the behavior:

When using node-fetch version 2.6.3, making a request to http://nginx/transactions/total?month=2021-09 do not send the url params. If I am using node-fetch version 2.6.1 everything work fine. Enabling node http verbose log, when making the request using node-fetch version 2.6.1 I get:

HTTP 52: createConnection nginx:80: {
  protocol: 'http:',
  slashes: true,
  auth: null,
  host: 'nginx',
  port: 80,
  hostname: 'nginx',
  hash: null,
  search: '?month=2021-09',
  query: 'month=2021-09',
  pathname: '/api/transactions/total',
  path: null,
  href: 'http://nginx/api/transactions/total?month=2021-09',
  method: 'GET',
  headers: [Object: null prototype] {
    Authorization: [
      'Bearer ....'
    ],
    Accept: [ '*/*' ],
    'User-Agent': [ 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)' ],
    'Accept-Encoding': [ 'gzip,deflate' ],
    Connection: [ 'close' ]
  },
  agent: undefined,
  servername: 'nginx',
  _agentKey: 'nginx:80:'
}

but using node-fetch version 2.6.3 I get

HTTP 24: createConnection nginx:80: {
  path: null,
  pathname: '/api/transactions/total',
  hostname: 'nginx',
  protocol: 'http:',
  port: 80,
  hash: '',
  search: '?month=2021-09',
  query: undefined,
  href: 'http://nginx/api/transactions/total?month=2021-09',
  method: 'GET',
  headers: [Object: null prototype] {
    Authorization: [
      'Bearer ....
    ],
    Accept: [ '*/*' ],
    'User-Agent': [ 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)' ],
    'Accept-Encoding': [ 'gzip,deflate' ],
    Connection: [ 'close' ]
  },
  agent: undefined,
  host: 'nginx',
  servername: 'nginx',
  _agentKey: 'nginx:80:'
}

Note the query part is undefined when using node-fetch version 2.6.3.

Expected behavior

The behaviour of the two versions should be the same.

Screenshots

Your Environment

software version
node-fetch 2.6.3
node 14.17.3
npm 6.14.3
Operating System linux

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions