Describe the bug
I want to get a response as string even if that comes as application/json. Parsing the response to an object is not required and not desired as the only thing I have to do with it is rewrite some urls and I am not sure of the content type the server will use.
To Reproduce
Server:
const http = require("http");
const server = http.createServer((req, res) => {
res.writeHead(200, {"Content-Type": "application/json"});
res.end("{\"doNotParse\": 1}");
});
server.listen(1234);
Client:
const axios = require("axios");
axios.request({url: "http://localhost:1234/", responseType: "text"})
.then(res => console.log("Type of data is %s", typeof res.data));
Outcome:
Type of data is object
Expected behavior
response data should be the string "{\"doNotParse\": 1}", the program would print:
Type of data is string
Environment:
- Axios 0.19.2
- Fedora 31
- Node 12
Additional context/Screenshots
Setting transformResponse: (data) => data appears to do the trick, regardless of responseType.
Describe the bug
I want to get a response as string even if that comes as application/json. Parsing the response to an object is not required and not desired as the only thing I have to do with it is rewrite some urls and I am not sure of the content type the server will use.
To Reproduce
Server:
Client:
Outcome:
Expected behavior
response
datashould be the string"{\"doNotParse\": 1}", the program would print:Environment:
Additional context/Screenshots
Setting
transformResponse: (data) => dataappears to do the trick, regardless ofresponseType.