question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use the proper transformers for specific `dataType` and `responseType` values.

See original GitHub issue

Implement and document proper transformation of request and response body according to dataType and responseType options.

This will fix: #375, #448, #765, #793

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:13
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
Scriptimcommented, Apr 20, 2020

https://github.com/axios/axios/blob/6642ca9aa1efae47b1a9d3ce3adc98416318661c/lib/defaults.js#L57-L65

I really don’t think that the current default parsing behavior is sensible.

It may even cause the data to be altered under certain circumstances, e. g.: Let’s say a server sends a 16 character string (with according header) of digits: 4201172030730738. The default behavior would convert this to the integer value 4201172030730738, although this is obviously not a JSON object (even if it is a valid JSON value). In case the string is e.g. 9100000000000001 (i.e. > Number.MAX_SAFE_INTEGER), parsing will cause the value to be changed to 9100000000000000 due to inaccuracy of the float data type.

This is not a far-fetched example, but rather a problem that has really occurred and has required quite a bit of debugging. Especially since this is not adequately documented in my opinion.

I suggest that parsing to JSON is only done if the data is really in JSON format, i. e. the Content-Type header is set to application/json and/or the value of dataType/responseType is set accordingly.

2reactions
scudettecommented, Oct 9, 2020

Jut hit this bug as well but I did find a workaround which seems to work for me so might save someone else some time:

axios({
        responseType: 'blob',
        method: 'get',
        url: url,
        params: params,
 }).then((response) => response.data.text()};
Read more comments on GitHub >

github_iconTop Results From Across the Web

Referring raml types in Mule 4 project - MuleSoft Help Center
I imported the API in a Mule project. Is there a way to use or refer one of the above types in Mule...
Read more >
Six Datatype Transformer Functions for Data Pre-Processing ...
I focus on datatype conversion for Machine Learning, as well as how to create pandas functional statements using function chaining and placement ...
Read more >
Common Data Formats for Inference - Amazon SageMaker
Use Batch Transform with Built-in Algorithms. While running batch transform, we recommended using the JSONLINES response type instead of JSON, if supported by ......
Read more >
Classification and regression - Spark 3.3.1 Documentation
Use the family parameter to select between these two algorithms, or leave it unset and Spark will infer the correct variant. Multinomial logistic...
Read more >
Web on Reactive Stack - Spring
Individual chapters cover the Spring WebFlux framework, ... to re-use knowledge while also selecting the right tool for the right job.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found