question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with query params

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:18
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

9reactions
jimmywartingcommented, Sep 21, 2021

Sorry about this, looking into it

3reactions
pimterrycommented, Sep 21, 2021

v2.6.4 was just released, and fixes this for me 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's the problem with required query parameters?
When reviewing API designs, I often encounter operations such as GET /resources?queryParameter=value where the query parameter is required.
Read more >
Routing with query params not working - Stack Overflow
Try this: this.router.navigate(['/inventory/client'], { queryParams: { id: this.vendorId} });. And have a look here: Passing Optional ...
Read more >
DRF: Is it possible to error when given invalid query params ...
I am working on a project with other python programmers and they want the API to return a 422 when list filtering with...
Read more >
Consuming rest api - problem with formatting query parameter
Consuming rest api - problem with formatting query parameter. Question. REST. Hello,. I am using version 11.6.27 Build 11455, and I am working...
Read more >
Redirect Issue – Query Param Underscore - WordPress.org
It's failing as a source. If there is underscore in query string parameters in source then query string parameters are not passed to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found