$ npm i -S kinka-serializy
# or using yarn
$ yarn add kinka-serializy
import kinka from 'kinka'
import KinkaSerializy from 'kinka-serializy'
const api = kinka.create({
baseURL: 'https://your-api.com',
middlewares: [
KinkaSerializy
]
})
// ...
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:
const api = kinka.create({
baseURL: 'https://your-api.com',
middlewares: [
KinkaSerializy({
errorModel: YourPrettifiedErrorModel
})
]
})
Licensed under the MIT License.