https://github.com/kao-xiang/bunios
Axios Alternative But For Bun
https://github.com/kao-xiang/bunios
axios bun fetch
Last synced: about 1 month ago
JSON representation
Axios Alternative But For Bun
- Host: GitHub
- URL: https://github.com/kao-xiang/bunios
- Owner: kao-xiang
- Created: 2025-02-07T20:02:30.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-02-07T20:03:03.000Z (over 1 year ago)
- Last Synced: 2025-08-30T23:42:53.434Z (10 months ago)
- Topics: axios, bun, fetch
- Language: TypeScript
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Bunios
Bunios is an Axios alternative or fetch wrapper for Bun with a predefined authPlugin that supports refresh tokens.
## Features
- Simple and intuitive API similar to Axios
- Built-in authentication plugin with refresh token support
- Lightweight and fast
- Fully compatible with Bun
## Installation
```bash
bun add bunios
```
## Usage
```javascript
import bunios from "bunios";
// Initialize bunios with your configuration
const apiClient = bunios;
apiClient.use(
buniosAuth({
getAccessToken: () => localStorage.getItem("accessToken"),
setAccessToken: (res) =>
localStorage.setItem("accessToken", res.data.access_token),
getRefreshToken: () => localStorage.getItem("refreshToken"),
setRefreshToken: (res) =>
localStorage.setItem("refreshToken", res.data.refresh_token),
maxRefresh: 1,
onError: console.error,
onRefreshError: console.error,
loginPath: "/auth/login",
refreshPath: "/auth/refresh",
})
);
// Make a request
apiClient
.get("/endpoint")
.then((response) => {
console.log(response.data);
})
.catch((error) => {
console.error(error);
});
```
## Contributing
Contributions are welcome! Please open an issue or submit a pull request.
## License
This project is licensed under the MIT License.