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

Error response data nodejs #5298

Closed
macductan opened this issue Nov 23, 2022 · 58 comments · Fixed by #5306 · May be fixed by #5300
Closed

Error response data nodejs #5298

macductan opened this issue Nov 23, 2022 · 58 comments · Fixed by #5306 · May be fixed by #5300

Comments

@macductan
Copy link

Describe the bug

`
var axios = require('axios');
var data = JSON.stringify({
"production_status": "",
"package_status": [],
"extra_status_reason": [],
"page": 1,
"limit": 1
});

var config = {
method: 'post',
url: 'https://example.com/',
headers: {
'Authorization': 'Bearer token',
},
data: {
"production_status": "",
"package_status": [],
"extra_status_reason": [],
"page": 1,
"limit": 1
}
};

axios(config)
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
`

When i send API this response
image
I want respose must be json like that
image

To Reproduce

No response

Code snippet

No response

Expected behavior

No response

Axios Version

1.2.0

Adapter Version

No response

Browser

No response

Browser Version

No response

Node.js Version

14.20.1

OS

No response

Additional Library Versions

No response

Additional context/Screenshots

No response

@dgurinovych
Copy link

dgurinovych commented Nov 23, 2022

I'm getting the same error after upgrading to 1.2.0 :(

More discussion here: #5296

@ddugovic
Copy link

ddugovic commented Nov 23, 2022

Ditto with GET https://lichess.org/api/user/Toadofsky?trophies=true

const axios = require('axios');
...
    const username = 'Toadofsky';
    const url = `https://lichess.org/api/user/${username}`;
    return axios.get(url, { headers: { Accept: 'application/json' }, params: { trophies: true } })
        .then(response => formatProfile(response.data))

Routing through proxy server BeeCeptor I can observe that Lichess response data are valid, however axios 1.2.0 does not handle the gzip encoding:

    _header: 'GET /api/user/Toadofsky?trophies=true HTTP/1.1\r\n' +
      'Accept: application/json\r\n' +
      'User-Agent: axios/1.2.0\r\n' +
      'Accept-Encoding: gzip, deflate, br\r\n' +
      'Host: lichess.free.beeceptor.com\r\n' +
      'Connection: close\r\n' +
      '\r\n',

@cetteup
Copy link

cetteup commented Nov 23, 2022

I'm also seeing this, plain old GET requests in my case.

@davidfilat
Copy link

I have the same problem since upgrading to 1.2.0
CleanShot 2022-11-23 at 13 10 47@2x

@dgurinovych
Copy link

dgurinovych commented Nov 23, 2022

The temporary workaround is to set Accept-Encoding header to something other than gzip, deflate, be - application/json for instance. And loose compressed data exchange of course.

@ddugovic
Copy link

Indeed, that workaround works in my case... based upon https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding I select identity:

    return axios.get(url, { headers: { Accept: 'application/json', 'Accept-Encoding': 'identity' }, params: { trophies: true } })

@davidfilat
Copy link

Indeed, that workaround works in my case... based upon https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding I select identity:

    return axios.get(url, { headers: { Accept: 'application/json', 'Accept-Encoding': 'identity' }, params: { trophies: true } })

Thank you! Worked for me!

@ddugovic
Copy link

ddugovic commented Nov 23, 2022

Can a maintainer confirm that manually adding Accept-Encoding: identity to every GET request is not the intended way to use axios (i.e., this issue is a regression)?

it('should support disabling automatic decompression of response data', function(done) {

@SSANSH
Copy link

SSANSH commented Nov 23, 2022

+1

1 similar comment
@jweingarten
Copy link

+1

@jeffersonfelixdev
Copy link

jeffersonfelixdev commented Nov 23, 2022

Same problem here with gzip response and axios 1.2.0

@ddugovic
Copy link

I've started migrating all my applications to fetch https://blog.logrocket.com/fetch-api-node-js/

@Aniket-Engg
Copy link

I also see this

@valbofs
Copy link

valbofs commented Nov 23, 2022

Indeed, that workaround works in my case... based upon https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding I select identity:

    return axios.get(url, { headers: { Accept: 'application/json', 'Accept-Encoding': 'identity' }, params: { trophies: true } })

Thank you!! This fixed it!

@semsturgut
Copy link

I spent my whole day because of this problem...😩

@andreyanez
Copy link

Indeed, that workaround works in my case... based upon https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding I select identity:

    return axios.get(url, { headers: { Accept: 'application/json', 'Accept-Encoding': 'identity' }, params: { trophies: true } })

Thank you! I was wrestiling with this problem yesterday

@alisson-acioli
Copy link

This is serious. Here at the company it stopped working when npm install was given in my package and there was a lot of support, luckily we decided to see if there was any update on axios. Here we solved leaving the version 1.1.13 that was running.

@nnfans
Copy link

nnfans commented Nov 24, 2022

spent hours to find this page 🤣
change package.json version for axios to lower "axios": "~1.1.0" and wait for the fix to be released

@deKadir
Copy link

deKadir commented Nov 24, 2022

i downgraded axios to ^0.19.2 it works now

@Myasir92
Copy link

I spent my entire day because of this same problem and fixed it by downgrading Axios to 1.1.3 🤣

.

@djaffer
Copy link

djaffer commented Nov 24, 2022

Same for me, I was scratching my head all day about what is broken. Reverting back to the previous version.

@dnohr
Copy link

dnohr commented Nov 24, 2022

Can confirm the issue as well. Unfortunately it's stopped working everywhere, just as with the v1 release. Looking forward to a fix, as I normally update all libraries to the latest via the npm-check-updates updater.

@ishaiavrahami
Copy link

same here getting issue

@ishaiavrahami
Copy link

this is ridiculous, other dependencies are reliant and system is down since yesterday

@marvasDE
Copy link

I have the same problem after updating from 1.1.3 to 1.2.0

@ja-ka
Copy link

ja-ka commented Nov 30, 2022

Why has this been closed as completed? The issue still persists in axios@1.3.0. I don't think that setting the Accept-Encoding: identify explicitly should be the favored solution.

@macductan macductan reopened this Nov 30, 2022
@MidnightTinge
Copy link

@macductan this will auto-close when #5306 merges, so it's fine to leave this open :) some people are tracking completion status here for the content-length regression so I'd just let github do its automated stuff

@renatocfrancisco
Copy link

same 👍🏻

@nitroo88
Copy link

same here :( currently 'Accept-Encoding': 'identity' works...

@ghazanfarali345
Copy link

{ headers: { Accept: 'application/json', 'Accept-Encoding': 'identity' },

It also worked for me in my case thanks bro

@cupidchan
Copy link

@jasonsaayman is this issue closed because it's really fixed in 1.3.1? Setting Accept-Encoding': 'identity is just a workaround but not the fix.

clareliguori added a commit to aws-samples/aws-reinvent-trivia-game that referenced this issue Dec 1, 2022
clareliguori added a commit to aws-samples/aws-reinvent-trivia-game that referenced this issue Dec 1, 2022
@jasonsaayman
Copy link
Member

No its close cause the PR that has the fix has been merged, this is how GitHub works. I will release this weekend

mikesprague added a commit to CU-CommunityApps/ct-az-common-alert-endpoint that referenced this issue Dec 2, 2022
@maximedupre
Copy link

For those that want to upgrade right now, use 1.2.0-alpha.1 (npm i axios@next)

@ricsantos
Copy link

For those fixing this by downgrading to 1.1.3, if you are using typescript you may want to downgrade further to 1.1.0 to avoid #5011

@jasonsaayman
Copy link
Member

Try the latest release v1.2.1 please

@salierykuba
Copy link

Indeed, that workaround works in my case... based upon https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding I select identity:

    return axios.get(url, { headers: { Accept: 'application/json', 'Accept-Encoding': 'identity' }, params: { trophies: true } })

thank you!, he has been fighting to solve this problem for three days;
I'm using :axios:1.2.0
but please fix that properly, because I don't think it's good to inject it into every get.
but thank you very much!

@PythonCoderAS
Copy link

You can always downgrade axios with no problems.

@frankiefab100
Copy link

Indeed, that workaround works in my case... based upon https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding I select identity:

    return axios.get(url, { headers: { Accept: 'application/json', 'Accept-Encoding': 'identity' }, params: { trophies: true } })

Thank you, you saved me a lot of time. It worked!

@razzeee
Copy link

razzeee commented Dec 8, 2022

A fix for this has already been released, why would you still want to use the workaround?

@salierykuba
Copy link

A fix for this has already been released, why would you still want to use the workaroundi

I Will update yep 👍

@samharvey44
Copy link

1.2.1 fixed issue, thanks. Drove me insane for hours..

@NunoSempere
Copy link

Hey, so I've been using axios for several years now, and I was really surprised that the problem I was having was coming from axios after all. Any ideas on why this happened, and what could be done to prevent similar issues in the future?

If the cause is e.g., a lack of manpower I would be e.g., happy to donate some amount so that axios can continue to be maintained (though i don't see a quick link to do this in the repo).

@djaffer
Copy link

djaffer commented Jan 23, 2023

I was also in surprise that did payload had change or something. Axios having an issue did not cross my mind. Version 1.2.3 should fix it, I think.

derhuerst added a commit to derhuerst/vbb-rest that referenced this issue Mar 11, 2024
The previous `~1.1` range was to work around axios/axios#5298.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet