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.

GET with parameters not just in the URL

See original GitHub issue

In some http clients, e.g. jQuery.ajax, it’s possible to not just put the params in the URL but an object. The client will mix/concat the params into the URL later. Is that possible to give params independently like

fetch("foo.json" {
  method: "get",
  params: {
    param1: "value1",
    param2: "value2",
  }
}).then(response => response.json())

to come up with a URL /foo.json&param1=value1&param2=value2?

Also, sometimes the params may be longer than the length limitation, so that some APIs accept GET requests with a body of parameters. So I don’t understand the reason fetch couldn’t GET with the body like

fetch("foo.json" {
  method: "get",
  body: {
    param1: "value1",
    param2: "value2",
  }
}).then(response => response.json())

Will these be behaviors allowed in the future? Maybe I can submit a pull request for these.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:20
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

25reactions
dgrahamcommented, Oct 15, 2015

Query parameters may be encoded natively with encodeURIComponent or with jQuery.param.

0reactions
fingermarkcommented, Oct 15, 2015

How is this solved today?

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Beginner's Guide to URL Parameters - SEMrush
In this comprehensive guide, we explore the ins and outs of URL parameters. Discover now how to use query strings without hurting your ......
Read more >
Why should HTTP GET parameters be part of url
If you want to talk purely REST, then the answer is simple, it depends entirely on the protocol you wish to use. REST...
Read more >
URL Get Parameter - Ryte
The getParameter() method is the HTTP request method most often used to request resources from a server through a client such as a...
Read more >
GET Parameters: Definition - Seobility Wiki
GET parameters (also called URL parameters or query strings) are used when a client, such as a browser, requests a particular resource from...
Read more >
How to Get URL Parameters with JavaScript - SitePoint
Here's a function to give you all the URL parameters as a neat object: function getAllUrlParams(url) { // get query string from url...
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