Hi there, Its Naman. This blog is for devs like me who use Axios frequently. I love Axios as it provides a clean API and advanced way to play around REST calls. Not only this, I even use Axios for simple GraphQL requests but sometimes I find myself just doing simple CRUD operations (GET, POST etc) using Axios which is overhead in my opinion. So, a couple of months back I found Redaxios. Its a nice little alternative and has been built by Jason Miller (creator of Preact).
Why would you use Redaxios instead of Axios
π Just one reason - Import Cost
I try my best to decrease the build size wherever I can. So, if you are someone like me and you are just doing basic RESTful calls then Redaxios is a great choice.
π¦ Import cost according to Bundlephobia
1- Axios (Link)
2- Redaxios (Link)
π€ How to use it?
The best thing about Redaxios is that it doesn't provide its custom API. Just use it like you use Axios.
π Installation
npm i redaxios --save
π Usage
import axios from 'redaxios';
(use as you would normally)
Tip: Start with Redaxios (if you are not sure) and down the line if you find that you need advanced features and Redaxios is not your cup of tea then just change the imports. That easy π
That's it for today. Feel free to provide any type of feedback. I do appreciate that. Meanwhile, you can find me on Twitter @InsaneNaman.
Signing off. See you soon.
Top comments (7)
Can someone make a version for typescript or a package @type/redaxios ?
Is there any issue while using Redaxios with TS? Afaik, It's compatible.
Here is the issue, how to fix it, I checked out the redaxios repo but can't find solution?
Need to see the whole code. If possible please put it on gist/GitHub.
Awesome! Thanks for sharing β€οΈπ―
The modern axios: xior.js
Another reason is that sentry can listen for native fetch but not XMLHTTPRequests