-
-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Closed
Description
Describe the bug
If you pass a response type of 'json' with a get request, it should automagically return the response.data as a parsed JSON object. Currently it comes back as a JSON string like if you set the ResponseType to 'text'.
To Reproduce
Call an API endpoint that returns JSON, and set the responseType on the get request to 'json'.
Code snippet
const instance = axios.create({
baseURL: '/api',
transformResponse: responseTransformer,
responseType: 'json',
});
const response = await instance.get("my/endpoint", { responseType: 'json' });
typeof response === 'string' // trueExpected behavior
In version 0.21.1, the requests were being parsed correctly, and I was getting a JS object back.
Axios Version
0.21.4
Adapter Version
No response
Browser
Chrome
Browser Version
116.0.5845.140
Node.js Version
14.19.3
OS
Fedora 37
Additional Library Versions
No response
abrain
Metadata
Metadata
Assignees
Labels
No labels
