https://github.com/acacode/axios-serializy
https://github.com/acacode/axios-serializy
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/acacode/axios-serializy
- Owner: acacode
- License: mit
- Created: 2019-07-22T07:19:57.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-07-17T21:52:49.000Z (almost 6 years ago)
- Last Synced: 2025-01-04T05:20:49.280Z (over 1 year ago)
- Language: JavaScript
- Size: 94.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
axios + serializy
[](./LICENSE)
[](https://www.npmjs.com/package/axios-serializy)
[](https://travis-ci.org/acacode/axios-serializy)
[](https://www.codefactor.io/repository/github/acacode/axios-serializy/overview/master)
[](http://npm-stat.com/charts.html?package=axios-serializy)
[](https://bundlephobia.com/result?p=axios-serializy)
[](https://bundlephobia.com/result?p=axios-serializy)
⚡️ Integration serializy with axios ⚡️
## 🚀 Installation
$ npm i -S axios-serializy
# or using yarn
$ yarn add axios-serializy
## 📚 Usage
```js
import axios from 'axios-serializy'
const api = axios.create({
baseURL: 'https://your-api.com'
})
// ...
const { data } = await api.get('/client/1234', {
model: ClientModel
})
console.log(data) // your serialized client model
```
Also if you want to serialize error messages from server you need to call `axios.setErrorModel(Model)`
Before creating axios instance
```js
axios.setErrorModel(YourPrettifiedErrorModel)
const api = axios.create({
baseURL: 'https://your-api.com'
})
```
## 📝 License
Licensed under the [MIT License](./LICENSE).