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

The agent() set default behavior is nonsensical #1783

Open
Louis-Tian opened this issue Sep 28, 2023 · 0 comments
Open

The agent() set default behavior is nonsensical #1783

Louis-Tian opened this issue Sep 28, 2023 · 0 comments

Comments

@Louis-Tian
Copy link

No mean to offend, but I find that agent's default setting behavior to be nonsensical.

I want the agent to manage the cookie for me. But I still need to send query with different query parameters in the requests.
Thinking this is a pretty common and reasonable use case. After all that's what happens if you make http request from a browser.

If I am not mistaken, the current api virtually prohibits you from doing that.
For example

const agent = superagent.agent()
await agent.get('/xyz').query({ id: 1 })
await agent.get('/xyz')                          // with ?id=1 
await agent.get('/xyz').query({id: undefined })  // without ?id=1
await agent.get('/xyz')                          // with ?id=1 again

The current api means the first query parameter you send automatically becomes the default for all of the subsequent requests and without any way of removing that default.

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

No branches or pull requests

1 participant