-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
responseType: 'text' return Json Object #907
Comments
This makes it impossible to get data from google.com and facebook because they prefix responces with |
It seems still uses JSON.parse or something. |
because:
|
This is because |
I've been bothered by this behaviour as well. In my case none of the data I am requesting is JSON and the caught JSON.parse exception was preventing me leaving "Pause on caught exception" on in my debugger.
|
Is there any progess on this issue? I was just caught out by this bug. I expected that |
Is it possible to override the default |
This is critical in case of validating json scheme before parsing or stream parsing. |
can be solved by passing
to axios or request configs |
can be solved by using arraybuffer as responseType axios.get('./test.txt', { responseType: 'arraybuffer' }).then(response => {
var buffer = new Buffer(response.data, 'binary');
var textdata = buffer.toString(); // for string
console.log(textdata);
var jsondata = buffer.toJSON(); // for json
console.log(jsondata);
}); |
@OzqurYalcin that returns In my case, I needed the responseType to be text so that the indentation could be preserved when fetching raw code (e.g. https://raw.githubusercontent.com/TwinProduction/show-my-ip/master/manifest.json), but it didn't work when the real response type was JSON due to Axios' automatic JSON parsing. However, @punksta's solution of setting |
Hope fix this issue soon. |
+1 |
Is anyone working on this? I'd be happy to take a stab at it. |
response.request.response is text |
@kvillaniholland I use |
I'm suffering under the same problem too.. It doesn't make sense. |
这都2019年了,这个bug居然还在。目前是 通过 重写 |
@390029659 我已经弃坑了,直接 100+ 行用 XmlHttpRequest 封了一个,完全用不着 axios 了,你要的话,我代码发你,很通用 |
@zozoh 好啊,学习瞻仰一下,提前谢谢了 |
@390029659 已经发你邮箱里了 |
i use 'transformResponse: undefined' , but fail this can be solved version 0.19.0 |
It's been over 2 years. What is blocking the issue? |
I have the same issue. I get |
The problem is the default |
This issue makes me almost speechless. What did the developers think when writing this? "So the user might not want JSON, but we'll try anyway and then override the user's choice" When is this kind of behaviour desired? A library that patronizes me like this is terrible. |
I'm sorry, but what makes me speechless is comments like this. Just don't, keep it to yourself. |
Nobody fix this bug? |
This bug still happens. Quite annoying when you fetch a piece of JSON data that you want to handle as a raw string. |
But:
The text was updated successfully, but these errors were encountered: