Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How you can send parameters in GET requests? #9

Closed
ericktucto opened this issue Nov 5, 2021 · 8 comments
Closed

How you can send parameters in GET requests? #9

ericktucto opened this issue Nov 5, 2021 · 8 comments
Labels
enhancement New feature or request

Comments

@ericktucto
Copy link

Please can you send a section where you can add the parameters that are GET requests

example

[Method]
GET
[Params]
page: 3

imagen

@jonaslu
Copy link
Owner

jonaslu commented Nov 6, 2021

I'm not sure I follow, do you mean /api/v2/todos?page=3, so the page: 3 would turn into page=3?

@ericktucto
Copy link
Author

Currently sending the parameters that way /api/v2/todos?page=3 , create this issue as a proposal to separate the endpoint from the sent parameters

@jonaslu jonaslu added the enhancement New feature or request label Nov 8, 2021
@jonaslu
Copy link
Owner

jonaslu commented Nov 8, 2021

Ok. I've thought about this some. In the one-file case it's not worth introducing a new section as you actually need to type more. But in the cascading case where you have base-files and more specific files for different endpoints it does makes sense.

An example is where you need to pass an API_KEY= to a bunch of endpoints as a query parameter. Since URL:s currently combine you need to specify that API_KEY in each of the last files pased to ain to get it in as a query-parameter. This leads to duplication.

If there was a [QueryParams] section that would also combine, but be placed after the first ? then it could be specified in a base-file and not duplicated.

Same goes for any fragment in the URL.

I'll flesh out the details in the coming days.

@jonaslu
Copy link
Owner

jonaslu commented Nov 23, 2021

So, I've added a [Query] section in ain v1.2.0. You can read up on the syntax here: https://github.com/jonaslu/ain#query

Note that parameters are written as they would be in an url with an equals sign (and whitespace within the key is significant):

page=3

It turns out i TIL that fragments are a client-side thing only and curl, wget and httpie ignores any fragment in the url, so I won't be doing those in the same way.

@jonaslu jonaslu closed this as completed Nov 23, 2021
@jonaslu
Copy link
Owner

jonaslu commented Nov 23, 2021

Oh, and thanks for the input.. 👍

@ericktucto
Copy link
Author

Thank you very much for including the new [Query] section 😀

@jonaslu
Copy link
Owner

jonaslu commented Nov 26, 2021

No problem. I changed so whitespace is not significant in the [Query] section in version v1.2.1

So these two are the same in v1.2.1 and onwards:

page=3
page = 3

@ericktucto
Copy link
Author

excellent, now i update ain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants