If the body is a string, Axios will add a double quotation mark to it.
See original GitHub issueDescribe the bug
A clear and concise description of what the bug is. If your problem is not a bug, please file under Support or Usage Question
If the body is a string, Axios will add a double quotation mark to it.
To Reproduce
Code snippet to reproduce, ideally that will work by pasting into something like https://npm.runkit.com/axios, a hosted solution, or a repository that illustrates the issue. If your problem is not reproducible, please file under Support or Usage Question
axios({
url: 'http://10.23.7.12:9090/api/service',
headers: {
'Content-Type': 'application/json'
},
method: 'post',
data: 'ggg'
})
The content received by the backend is "\" ggg \ ""

Expected behavior
A clear and concise description of what you expected to happen.
Environment
- Axios Version [e.g. 0.18.0] 0.21.4
- Adapter [e.g. XHR/HTTP] XHR
- Browser [e.g. Chrome, Safari] Chrome
- Browser Version [e.g. 22] 93.0.4577.63
- Node.js Version [e.g. 13.0.1] v16.7.0
- OS: [e.g. iOS 12.1.0, OSX 10.13.4] macOS Big Sur 11.2.3
- Additional Library Versions [e.g. React 16.7, React Native 0.58.0]
Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Axios adds extra trailing slash in body values - Stack Overflow
A very simple way to try this would be data: JSON.stringify(parsedBody).replace(/\\\\,/g, '\\,') . This will obviously not work if you ever ...
Read more >'Single' vs "Double" quotes for strings in javascript - Flexiple
Both single (' ') and double (" ") quotes are used to represent a string in Javascript. Choosing a quoting style is up...
Read more >Should I use 'single' or "double-quotes" for strings in JavaScript
You've seen both 'single quotes' and "double quotes" used for writing strings in JavaScript. You're wondering if they have any difference.
Read more >SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse() does not allow trailing commas · Property names must be double-quoted strings · Leading zeros and decimal points.
Read more >Understanding Axios GET requests - LogRocket Blog
How to install Axios in a Node.js project. In this section, we will create the sample app that uses Axios to fetch data...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is expected behavior.
gggis not a valid JSON string, it can’t be decoded with any standard JSON parser on the server-side. Use valid JSON or change content type toContent-Type: text/plainto send the payload as plain text.@AbdoShiabany This behaviour is implemented by the default transform request handler. So just replace it with your own implementation. Basically, this can be a function that returns the string payload as is.