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
After upgrade to 1.0 GET request with parameters in the url fail #4999
After upgrade to 1.0 GET request with parameters in the url fail #4999
Comments
Weird... |
Not really ... sorry. I can't give you access to our GIT server to make that GIT api call. I am not sure if its a generic thing with any parameters in the url or just this specific set. |
No need for git acces, just a 2 files repository on github with a nodejs script that calls an express server that throws the same error. Because the above information doesn't seem enough to find a precise solution. |
How about this? Curl command for illustration onlyFor illustration ... a curl command that returns with my personal GIT Access token a list of commits when searching the axios repo. As I said its just for illustration. If you want to execute the curl command you need to update the Request:
Response looks normal as I get a list of commits. Axios v1.0.0-alpha.1Steps/Run
Response looks normal as I get an array of commits back. Axios v1.0.0Steps/Run
Response
|
Forgot to mention ... I am testing with |
I am also having the same or similar issue, I was just studying and when I installed the new upgraded version my get call was returning a 404 not found status. I'm using
It works fine on the |
This might be an oversight but in v1 we have been a lot stricter with our If you use a URL like this |
That's ridiculous. I love axios and it's my goto client in node but this breaking change hurts the ergonomics of the library. |
I have the same problem as the original poster. Does this mean that, to send a request to an URL from elsewhere that may contain a query string, I have to detect the question mark, split the URL manually and put the querystring into the params? This probably also means that I should be using URLSearchParams to avoid writing a querystring parser myself, right? |
Same here, we're going to refactor but there is no mention of this in the breaking changes |
Fun fact, Can we get a word from Axios maintainers ? |
For those wondering, or too lazy to refactor everything, or using Axios to fetch full URLs they don't manage (our use case: we fetch a RSS feed containing links to items and the item URL might contain query params, it's an opaque string for us) I resorted to using this interceptor: instance.interceptors.request.use((req) => {
const url = new URL(axios.getUri(req)), // getUri will build the final URI, merging defaults
params = new URLSearchParams(url.searchParams);
url.search = '';
req.url = url.href; // The URL without query params
req.params = params; // The merged query params from defaults + request
return req;
}); In my context, I'm paying the extra CPU cycles for the useless interceptor. I'm hoping for Axios to reintroduce previous behavior |
Thanks, @ddolcimascolo. Is the order of the params deterministic? I'm using axios for an API that signs the search params and appends that as the last search param:
Where |
This is a very unfortunate breaking change which I hope the maintainers will reconsider. |
I'd say yes |
I can confirm this error as well after upgrading to v1.0. Simple scripts are failing, so I had to roll back to v0.27.2. Hope it's some simple issue which can easily be fixed. Thanks for working on the project! |
I can also confirm these errors as lots of our get requests are failing now and we had to rollback. |
Same here. Since most APIs, including nodejs include the search parameters in the URL object, this change is miss-leading in my opinion. Also, it is very strange to remove the |
@jasonsaayman @mzabriskie @nickuraltsev It's clear now that this goes beyond a simple whoopsie 😅 Do you agree on fixing this? If so, I'm willing to work on a PR if this is of any help. Cheers, |
@ddolcimascolo I would be very happy if you would do so :) |
This is definitely a bug. this disruptive change is not mentioned anywhere. |
Came here from this StackOverflow question. The docs still says that To resolve the discrepancy, either the library can be updated to support query params in URL strings (like in v0), or the docs can be updated to match the current v1 behavior. |
As I see no good reason for the New behaviour I would recommend to restore the one from v0 🙈 |
+1 |
Path including Query String is considered URL (URI) in HTTP semantics https://www.rfc-editor.org/rfc/rfc9110.html This changes break any application that accept URL as user input and pass directly as URL to axios.get(), post() and others. In case user supply query_params it should append to URL with & or ? as neccessary. |
+1 |
@jasonsaayman seems like PR #4852 should be reverted for now. Axios should definitely be able to parse params from a query string. Currently, these changes do more harm than good, since the problem they solve is not critical, but only potentially possible and has existed for years. This should be carefully considered from all points of view before such incompatibilities are introduced. Another, more thoughtful solution should be found. |
Clearly, this is a bug in Axios. new URL('https://api.example.com/path?bug=axios')
URL {
href: 'https://api.example.com/path?bug=axios',
origin: 'https://api.example.com',
protocol: 'https:',
username: '',
password: '',
host: 'api.example.com',
hostname: 'api.example.com',
port: '',
pathname: '/path',
search: '?bug=axios',
searchParams: URLSearchParams { 'bug' => 'axios' },
hash: ''
} |
* Fixes #4999; * Added regression test;
Fixed with #5018 |
Sorry about that, something that I should have picked up, I will try to be a bit more strict on changes which are to largely incompatible. |
Thx for fixing @jasonsaayman 👍 |
No probs but credit goes to @DigitalBrainJS. Sorry for all the problems this caused. Please can anyone interested watch our releases as we need many more testers on pre-releases, I can only do so much. |
Any idea on the date of the next release? Just to know if we rollback to 0.x or wait for the new release :) |
Releaseing now |
@jasonsaayman Why was the fix shipped in a minor release and not a patch? I would have expected v1.0.1 Won't this remain broken for anyone using approximate equivalent version? "axios": "~1.0.0" |
Thanks for fixing this issue so quickly, @jasonsaayman! |
Can confirm that it works for me. That was fast! Thanks a lot. |
Im bumping as minor cause its not the only change |
@jasonsaayman could you please roll out a v1.0.1 patch release with the URL query param fix then? That or pull v1.0.0 entirely. As mentioned already, anyone using ~1.0.0 won't get the fix |
Same issue. Though I think its partly because our app uses WebPack and not Rollup. |
Working request with Axios v1.0.0-alpha.1:
Same request with 1.0.0 fails with a 404. 1.0.0 was promoted today.
When I print the failed response it looks like something is parsed/encoded incorrectly.
To me the
?
is missing in betweencommits
andq
.When I don't parse the parameters on the URL and use
config.params
it works with Axios1.0.0
.The success response then shows this
_header
:In the working version I do see the
?
.So right now the workaround is either sticking with v1.0.0-alpha.1 or using config.params instead of passing them with the .get call.
The text was updated successfully, but these errors were encountered: