ctimmerm / axios-mock-adapter

Axios adapter that allows to easily mock requests
MIT License
3.47k stars 245 forks source link

Body defined as a string gets auto-converted to json #215

Closed jay-jlm closed 4 years ago

jay-jlm commented 5 years ago
axiosInstanceMock.onPost(/\.*/).reply(201, '{ "path": "upload_path" }');

result.data for the request above is of type object, however when using axios on the website I receive this data as a string from the server.

ctimmerm commented 4 years ago

This conversion is done by a default response transformer in axios itself: https://github.com/axios/axios/blob/master/lib/defaults.js#L57-L65.