developit / redaxios

The Axios API, as an 800 byte Fetch wrapper.

Home Page:https://npm.im/redaxios

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

discrepancy in response data

David5280 opened this issue · comments

Hey there,

I'm trying to convert some axios requests to redaxios and I'm noticing a discrepancy in the responses. The data object coming back from redaxios is stringified, whereas the data object I currently receive with axios is valid JSON. I am wondering if it would make sense to do this conversion in redaxios so that it is truly a drop-in replacement of axios?

Looking forward to hearing your thoughts, thanks!

Ah - I'm guessing Axios inspects the response headers and determines when JSON should be used rather than text. I think we can add that here. Good catch!

Actually the default value for responseType in axios is json. So to match the API of axios, redaxios should do the same.

Thanks for the tip @hasan-wajahat - I actually had read that wrong in the docs (I've never used Axios!). I amended the solution from #26 based on your comment.

This issue is now fixed in version 0.3.0.