$ npm i -S axios-serializy
# or using yarn
$ yarn add axios-serializy
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
axios.setErrorModel(YourPrettifiedErrorModel)
const api = axios.create({
baseURL: 'https://your-api.com'
})
Licensed under the MIT License.